Reported January 2021
Bloombergdynamic programming

Minimum-Step Right-Down Grid Path

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

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

Bloomberg reported this one in January 2021, and the title makes it sound like a shortest-path problem. It isn't, really. With only Right and Down moves, every path to the bottom-right has the same length, rows plus columns minus 2. So the real question is whether a path exists at all. That's the trap: you can write a full BFS and burn your time, or see the reduction and finish fast. If you blank during the live OA, StealthCoder runs invisibly on your desktop as a safety net and reads the problem for you.

The problem

In a binary grid, 1 is passable and 0 is blocked. Starting at the top-left, reach the bottom-right using only one-cell Right or Down moves. Return the minimum number of moves, or -1 if unreachable.

Function
minimumRightDownSteps(grid: int[][]) → int

Examples
Example 1
grid = [[1,0,1],[1,1,1],[0,1,1]]
return = 4
A path uses two down and two right moves.

Constraints
The rectangular grid has at most 10^6 cells.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick: in an m by n grid, any monotone path from top-left to bottom-right takes exactly (m-1)+(n-1) moves. Distance is fixed, so you only need reachability. Run a simple DP over the grid. A cell is reachable if it's 1 and the cell above or the cell to its left is reachable. Check the start cell first, because a 0 at the start or end means -1 right away. If the end is reachable, return m+n-2. In Example 1 that's 3+3-2 = 4, which matches. A BFS with a queue also works and fits the hinted pattern, but it's extra code. The common pitfall is forgetting to check the start and end cells, or mishandling a single-row or single-column grid. With up to 10^6 cells, O(m*n) time is fine, and you can use one rolling row for O(n) space. If your mind goes blank on the reduction, StealthCoder can surface the solution live.

The honest play: practice the pattern, and have StealthCoder ready for the one you didn't see coming.

If this hits your live OA

You can drill Minimum-Step Right-Down 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. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play.

Get StealthCoder

Related leaked OAs

⏵ The honest play

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

Bloomberg reuses patterns across OAs. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Minimum-Step Right-Down Grid Path FAQ

How hard is the Minimum-Step Right-Down Grid Path problem really?+

Easy once you spot the reduction. Every Right/Down path has the same length, m+n-2, so you only check reachability. The difficulty is overthinking it as a shortest-path problem. Candidates who jump straight to BFS still pass, they just write more code than needed.

What's the trick for this Bloomberg OA question?+

Distance is constant for monotone paths. Compute reachability with a DP: a cell is reachable if it's 1 and its top or left neighbor is reachable. If the bottom-right is reachable, return rows+cols-2. Otherwise return -1.

Should I use BFS or DP here?+

Either passes. BFS matches the usual hint and handles it cleanly with a queue and visited set. DP is shorter and uses less memory since you only look at top and left neighbors. With 10^6 cells at most, both run in linear time.

What edge cases break solutions?+

A blocked start or end cell, which should return -1. A 1x1 grid with a 1, which should return 0. Single-row or single-column grids, where one blocked cell kills the path. Also watch out-of-bounds checks when looking up and left.

How do I prepare for this in 48 hours?+

Practice grid reachability with direction-limited moves, and write both the DP and BFS versions once. Then test the edge cases above by hand. Since Bloomberg reported this in January 2021, expect grid-path variants with small twists like blocked cells or counted paths.

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

OA at Bloomberg?
Invisible during screen share
Get it