Reported September 2026
Capital Onesimulation

Diagonal Robot Path Sum

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

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

The Capital One OA reported in September 2026 looks like a graph problem, but it's a simulation with a bouncing robot. Candidates lose points in the first ten minutes by getting the bounce rule wrong, then burning time debugging off-by-one errors on a grid. You get a matrix, a start cell, and a diagonal walker that reflects off walls. Add values, stop on a corner or a repeat. It's short to code and easy to botch. If you blank on the reflection logic during the live OA, StealthCoder sits invisibly on your screen and gives you a working solution while you stay calm.

The problem

You are given an integer matrix matrix and a starting cell (cellX, cellY). Coordinates are zero-based: cellX is the row and cellY is the column.
A robot starts at that cell, includes its value in a running sum, and initially moves diagonally in direction (+1, +1).
Before each move, consider the next row and column. Reverse the row direction if the next row would leave the matrix. Independently reverse the column direction if the next column would leave the matrix.
Move one cell diagonally using the resulting directions.
If the destination was visited earlier, stop without adding its value again.
Otherwise add the destination value. Stop if it is one of the four corners; if it is not, mark it visited and continue.
Return the collected sum. The starting cell is guaranteed not to be a corner.

Function
solution(matrix: int[][], cellX: int, cellY: int) → long

Examples
Example 1
matrix = [[1,2,3],[4,5,6],[7,8,9]]
cellX = 1
cellY = 1
return = 14
The start (1,1) contributes 5. The next cell (2,2) is a corner, so add 9 and stop: 14.
Example 2
matrix = [[1,2,3,4],[5,6,7,8],[9,10,11,12]]
cellX = 1
cellY = 1
return = 28
The distinct visited cells (1,1), (2,2), (1,3), (0,2) contribute 6 + 11 + 8 + 3 = 28. The next cell is the previously visited start, whose value is not counted twice.

Constraints
2 ≤ matrix.length ≤ 500
2 ≤ matrix[0].length ≤ 500
Every row has the same length.
-1000000000 ≤ matrix[r][c] ≤ 1000000000
The starting coordinates identify a valid non-corner cell.
Use a signed 64-bit integer for the sum.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick is that there's no real graph search. The path is deterministic, so you simulate it step by step with a visited set. The mistake that sinks a first attempt is flipping direction after moving instead of before. You check the next row and next column first, flip each direction independently if it would leave the matrix, then move. Both can flip on the same step. Second pitfall: when the destination is already visited, you stop without adding its value. Third, check the corner only after adding the value, and only on a fresh cell. Use a 64-bit sum since values reach a billion across up to 250,000 cells. A boolean grid works as the visited set. The path can't run forever because states are finite. If the reflection order gets tangled mid-assessment, StealthCoder is the hedge that hands you the clean loop.

Drill it cold or hedge it with StealthCoder. Either way, don't walk into the OA hoping you remember the trick.

If this hits your live OA

You can drill Diagonal Robot Path Sum 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 for the candidate who got the OA invite this morning and has 72 hours, not six months.

Get StealthCoder

Related leaked OAs

⏵ The honest play

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

Capital One reuses patterns across OAs. Made for the candidate who got the OA invite this morning and has 72 hours, not six months. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Diagonal Robot Path Sum FAQ

How hard is the Diagonal Robot Path Sum problem really?+

Easy to medium. There's no clever algorithm, just careful simulation. The difficulty is the order of operations: check bounds, flip directions, move, check visited, add value, check corner. Most failures come from doing those steps in the wrong order, not from complexity.

What's the trick to the bounce logic?+

Look at the next cell before moving. If row + dx is out of range, negate dx. If col + dy is out of range, negate dy. These checks are independent, so both can flip at once. Then move using the updated directions. Never move first and fix afterward.

Do I need BFS or DFS even though it's tagged graph?+

No. Each cell has exactly one successor, so the path is a single chain. A while loop with a visited grid is enough. Treat it as a simulation. Using a queue or recursion just adds risk of mistakes and stack issues.

Why do I get wrong answers on Example 2?+

Usually you either re-add the start cell's value when the robot returns, or you mark cells visited before checking them. Check visited on the destination first. If it's seen, stop without adding. Otherwise add, test for a corner, then mark visited.

How should I prepare in 48 hours for a Capital One OA like this?+

Practice grid simulations with direction flipping and visited sets. Write one from scratch and trace the examples by hand. Watch integer overflow, since the sum needs 64 bits. Focus on clean step ordering rather than learning new algorithms.

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

OA at Capital One?
Invisible during screen share
Get it