Reported October 2026
Pineconematrix

Set Matrix Zeroes

Reported by candidates from Pinecone's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Pinecone OA. Under 2s to a working solution.
Founder's read

Pinecone reported this one in October 2026, and the detail that matters is in the statement: modify the input matrix and return it. Set Matrix Zeroes looks like a grid problem, but it's really a marking problem. If you zero cells as you scan, you'll wipe out rows and columns that were never zero to begin with. The hinted pattern says BFS, but you don't need it. Two passes over the matrix does the job. If you blank on the in-place version during the live OA, StealthCoder runs invisibly as a safety net and gives you the approach while you keep typing.

The problem

Given an m x n integer matrix matrix, if any cell is 0, set every cell in that row and column to 0.
Modify the input matrix and return the transformed matrix.

Function
setZeroes(matrix: int[][]) → int[][]

Examples
Example 1
matrix = [[1,1,1],[1,0,1],[1,1,1]]
return = [[1,0,1],[0,0,0],[1,0,1]]
The middle row and column contain the original zero, so both become zero.
Example 2
matrix = [[0,1,2,0],[3,4,5,2],[1,3,1,5]]
return = [[0,0,0,0],[0,4,5,0],[0,3,1,0]]
The original zeroes mark the first row and the first and fourth columns.

Constraints
1 <= m, n <= 200.
-2^31 <= matrix[i][j] <= 2^31 - 1.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick is separating detection from mutation. Pass one finds every original zero and records its row and column. Pass two zeroes those rows and columns. The simple version uses two boolean arrays of size m and n, which is O(m+n) extra space and easy to get right. The tighter version stores the markers in the first row and first column of the matrix itself, with two extra flags for whether that first row or column originally held a zero. The classic pitfall is zeroing during the first scan, which cascades and turns the whole grid to zero. Another is forgetting the first row and column flags in the in-place version. With m and n capped at 200, the simple version is fine unless the assessment asks for constant space. If the in-place bookkeeping slips away mid-OA, StealthCoder is the hedge that keeps you from burning your clock on it.

Memorize the pattern. If you can't, run StealthCoder. The proctor sees the IDE. They don't see what's behind it.

If this hits your live OA

You can drill Set Matrix Zeroes cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge.

Get StealthCoder

Related leaked OAs

⏵ Practice the LeetCode equivalent

This OA pattern shows up on LeetCode as set matrix zeroes. If you have time before the OA, drill that.

⏵ The honest play

You've seen the question. Make sure you actually pass Pinecone's OA.

Pinecone reuses patterns across OAs. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Set Matrix Zeroes FAQ

What's the trick in Set Matrix Zeroes?+

Don't zero cells while you scan. First record which rows and columns contain an original zero, then apply the zeroing in a second pass. Mixing the two steps creates new zeros that get mistaken for original ones and spreads zeros everywhere.

Do I need BFS for this Pinecone problem?+

No. Despite the hinted BFS label, nothing here needs graph traversal. It's a plain two-pass matrix scan. Zeros affect their whole row and column directly, so there's no spreading from cell to neighbor to model with a queue.

How hard is it really?+

Easy to medium. The O(m+n) marker-array solution is straightforward. The constant-space version is where people slip, because you reuse the first row and column as storage and must track their own zero status separately before overwriting them.

What edge cases should I test?+

Test a single row, a single column, and a 1x1 matrix. Test a zero in the first row or column, since that breaks naive in-place marking. Also test a matrix with no zeros and one that's all zeros. Negative values and extreme integer values behave like any nonzero.

How do I prepare in 48 hours?+

Write the two-array version from memory until it's automatic. Then write the in-place version once, carefully tracking the first row and column flags. Trace Example 2 by hand. That covers what Pinecone's statement shows, and it's a short job.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Pinecone.

OA at Pinecone?
Invisible during screen share
Get it