Reported July 2026
OpenAIdynamic programming

DSA Round: Maximum Score Grid Path

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

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

The mistake that sinks most first attempts at this OpenAI grid problem is treating it as a plain 2D DP and forgetting the jump counter. The OpenAI problem was reported in July 2026. You start at (0,p), move down through a grid with three normal moves plus a limited two-row jump, and return three things: the max score, the lexicographically smallest best path, and the count of best paths mod 10^9+7. If you've got an OA coming, know the state before you write code. StealthCoder runs invisibly as a safety net on the live OA if you blank on the tie-breaking.

The problem

You are given a rectangular grid board of size N x M, where each cell contains an integer. A player starts from cell (0, p) in the top row. The objective is to reach the bottom row of the grid while maximizing the total score collected.
From a cell (i, j), the player may move to:
(i + 1, j - 1), diagonally left-down
(i + 1, j), straight down
(i + 1, j + 1), diagonally right-down
(i + 2, j), using a special jump move
The player must always remain inside the grid boundaries. The special jump move (i + 2, j) may be used at most k times during the traversal.
The total score is equal to the sum of all visited cell values, including the starting cell and the final cell.
Complete the function maximizeGridPathScore. It should return a String[] with exactly three values:
result[0]: the maximum achievable score from the starting cell to any cell in the last row.
result[1]: one path that produces the maximum score, formatted as coordinates joined by ->, for example (0,1)->(1,1).
result[2]: the number of distinct maximum-score paths modulo 10^9 + 7.
If multiple maximum-score paths exist, return the lexicographically smallest coordinate sequence as the path in result[1]. Compare two paths by their coordinate pairs from left to right; the smaller row wins first, then the smaller column.
What the interview report shared
The source described an OpenAI onsite DSA round problem about maximizing score while moving through a rectangular integer grid. It listed the four allowed moves, including a limited special jump, and asked for the maximum score, one maximum-score path, and the count of maximum-score paths modulo 10^9 + 7.
How FastPrep adapted it
FastPrep kept the source task and example board, and added a deterministic return format so the problem can be practiced and checked here. The source asked for one valid maximum-score path but did not specify how to choose among ties, so FastPrep uses the lexicographically smallest maximum-score coordinate sequence for that returned path.

Function
maximizeGridPathScore(board: int[][], p: int, k: int) → String[]

Examples
Example 1
board = [[1,2,3,4],[5,6,1,2],[7,8,9,1],[3,2,5,6]]
p = 1
k = 1
return = ["23","(0,1)->(1,1)->(2,2)->(3,3)","1"]
One maximum-score path is (0,1)->(1,1)->(2,2)->(3,3).
Visited values: 2 + 6 + 9 + 6 = 23.
The alternate valid jump path shown in the source, (0,1)->(2,1)->(3,2), scores 2 + 8 + 5 = 15, so it is not a maximum-score path.
There is exactly one maximum-score path for this example.
The source image provided valid path examples but did not state the final output values; these values follow directly from the source board and movement rules.

Constraints
board is rectangular and contains integers.
p is a valid column index in the top row.
The player may use the special jump at most k times.
Return the maximum-path count modulo 10^9 + 7.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick is that state is (row, col, jumpsUsed). Every move goes strictly down, so the graph is a DAG and you can do DP row by row. BFS-style layering works, but a forward or backward DP is cleaner. Keep three values per state: best score, path count mod 1e9+7, and a way to rebuild the smallest path. Pitfall one: dropping the k dimension, so jumps get overused. Pitfall two: counting paths with a mod on the score, or adding counts when scores are strictly less. Only add counts on ties. Pitfall three: lexicographic ties. Compute DP from the bottom up (best from this state to the end), then walk forward from (0,p) and at each step pick the smallest (row, col) among moves that preserve the optimum. Final answer takes the max across last-row cells and all jump counts up to k, summing counts of ties. StealthCoder is your hedge if the reconstruction logic slips live.

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 DSA Round: Maximum Score Grid Path 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 OpenAI's OA.

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

DSA Round: Maximum Score Grid Path FAQ

What's the trick in the OpenAI maximum score grid path problem?+

Add the jump count to your DP state. Each state is (row, col, jumps used). Since all moves go down, process rows in order. Track max score and number of ways to hit it. Everything else, including path reconstruction, falls out of that state.

How do I get the lexicographically smallest path?+

Run the DP backward so each state knows its best score to the finish. Then walk forward from (0,p). At each step, among moves that keep the total optimal, choose the one with the smaller row, then smaller column. Greedy works because the suffix values are already exact.

How do I count maximum-score paths correctly?+

Per state, keep a count alongside the score. When a next state offers a higher score, replace the count. When it ties, add the counts mod 1e9+7. When it's lower, ignore it. At the end, sum counts over all last-row cells and jump totals that hit the global max.

Is BFS actually needed here?+

Not really. The hint says breadth-first, but the grid is a DAG with strictly increasing rows, so row-by-row DP is simpler and faster. Layered BFS gives the same result if you prefer it, as long as the state includes jumps used.

How do I prepare for this in 48 hours?+

Write the DP once on the sample board and check you get 23, the path (0,1)->(1,1)->(2,2)->(3,3), and count 1. Then test edge cases: k=0, a single row, and a grid where many paths tie. Those cover the common failures.

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

OA at OpenAI?
Invisible during screen share
Get it