Reported September 2026
Googledynamic programming

Count Matrix Paths Through Ordered Checkpoints

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

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

Google reported this one in September 2026, and the hinted tag says BFS, but the structure that matters is a rolling 1D array of path counts per row. You start bottom-left, move one column right each step, shift the row by -1, 0, or +1, and you have to hit every checkpoint in order. If the OA lands in your inbox this week, this is a column-by-column DP dressed up as a grid walk. StealthCoder sits invisibly on your screen as a safety net if you blank mid-assessment, but the idea is small enough to hold in your head tonight.

The problem

Start at (rows-1,0) and finish at (rows-1,columns-1). Every move advances one column and changes the row by -1, 0, or +1 while remaining in bounds.
Count paths that visit every listed checkpoint in the given order. Checkpoints have strictly increasing columns and may include either endpoint. Return the count modulo 1,000,000,007.

Function
countCheckpointPaths(rows: int, columns: int, checkpoints: int[][]) → int

Examples
Example 1
rows = 3
columns = 4
checkpoints = [[1,1],[2,3]]
return = 2
Two choices reach the first checkpoint and two more steps finish at the required endpoint.
Example 2
rows = 1
columns = 5
checkpoints = []
return = 1
With one row, there is exactly one path.
Example 3
rows = 2
columns = 2
checkpoints = [[0,1]]
return = 0
The checkpoint conflicts with the required bottom-right destination, so no path qualifies.

Constraints
1 <= rows, columns <= 1000.
Checkpoint coordinates are valid and columns are strictly increasing.

Reported by candidates. Source: FastPrep

Pattern and pitfall

Treat each column as one layer. Keep an array dp of size rows, where dp[r] is the number of ways to be at row r in the current column. Start with dp[rows-1] = 1 at column 0. To advance, new[r] = dp[r-1] + dp[r] + dp[r+1], bounds checked, mod 1,000,000,007. That's a layered BFS that merges counts instead of visiting nodes, and it runs in O(rows * columns). For checkpoints, after computing a column that holds a checkpoint, zero every cell except the checkpoint row. That forces the path through it. Order is automatic because columns strictly increase and you sweep left to right. The pitfall is forgetting the end: read dp[rows-1] at the last column, and if a checkpoint in that column sits elsewhere, you get 0, which is Example 3. Also handle a checkpoint at column 0 that isn't the start row. Apply the mod on every addition. If you freeze live, StealthCoder is the hedge, but the zero-out trick is the whole problem.

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 Count Matrix Paths Through Ordered Checkpoints 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

⏵ The honest play

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

Google 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.

Count Matrix Paths Through Ordered Checkpoints FAQ

What's the actual trick in Count Matrix Paths Through Ordered Checkpoints?+

Do a column-by-column DP. Each cell's count is the sum of the three neighbors in the previous column. At a checkpoint column, wipe every row except the checkpoint row. That enforces the visit without any extra state or path tracking.

Do I need real BFS with a queue for this?+

No. The BFS tag fits loosely because you expand layer by layer, but a queue would be wasteful. A rolling array of counts per row does the same job in O(rows * columns) time and O(rows) space, which easily fits the 1000 by 1000 limits.

How do I handle the endpoint cases and the zero answer?+

Start with dp[rows-1] = 1 in column 0. If a checkpoint is in column 0 on a different row, the answer is 0. Same at the last column: a checkpoint not on row rows-1 kills everything, as in Example 3. Just apply the zeroing rule uniformly.

Where do people lose points on this one?+

Mostly the modulus and bounds. Forgetting mod on each addition overflows in some languages. Reading dp[r-1] or dp[r+1] out of range crashes. Also, don't update in place. Build a fresh array per column or you'll double count moves.

How do I prepare in 48 hours for the Google OA with a problem like this?+

Be able to write the grid-path DP with a rolling array from memory, then add one twist: forced cells by zeroing others. Test the three examples by hand, especially the single-row and conflicting-endpoint cases. That covers most of what this question checks.

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

OA at Google?
Invisible during screen share
Get it