Minimum Falling Path Sum II
A hard-tier problem at 64% community acceptance, tagged with Array, Dynamic Programming, Matrix. Reported in interviews at Roblox and 0 others.
Minimum Falling Path Sum II is a hard matrix DP problem with a 64% acceptance rate. You pick one element from each row, but you can't pick from the same column twice in a row. It looks like the simpler falling-path problem until you realize the column constraint flips everything. Roblox has asked this. The trap: brute force recursion or naive DP will time out. You need to recognize the optimization that cuts complexity from O(n^3) to O(n^2), or you'll blank mid-OA. If that happens and you're in the assessment, StealthCoder solves it invisibly while you stay calm.
Companies that ask "Minimum Falling Path Sum II"
Minimum Falling Path Sum II is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Built by an engineer at a top-10 tech company who can solve these problems cold but didn't want to trust himself in a 90-minute screen share.
Get StealthCoderThe core insight is that you can't use a simple 1D DP where you track the minimum from the previous row. You need to know both the minimum and second-minimum column values from each row, because if the previous minimum came from column j, your current pick must come from any column except j. Build a DP table where dp[i][j] is the minimum cost to reach row i, column j. For each cell, scan the entire previous row, but skip the column that gave the previous row's minimum. The second-minimum trick lets you avoid a full O(n^3) scan. Common failure: trying to optimize prematurely or misunderstanding the no-same-column rule. StealthCoder catches both and delivers the second-minimum pattern instantly if you hit this during screen share.
Pattern tags
You know the problem.
Make sure you actually pass it.
Minimum Falling Path Sum II recycles across companies for a reason. It's hard-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Built by an engineer at a top-10 tech company who can solve these problems cold but didn't want to trust himself in a 90-minute screen share. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Minimum Falling Path Sum II interview FAQ
Is this just the regular falling path problem with an extra rule?+
No. Regular falling path lets you move to adjacent columns (diagonal moves). This one lets you move to any column except the one you came from in the previous row. That constraint removal actually makes it harder because the search space explodes. The optimization is the real challenge here.
Why does my O(n^3) solution time out?+
For each of n^2 cells, you're scanning the entire previous row to find the minimum excluding one column. That's O(n^3) total. The fix: precompute the row minimum and second-minimum in a single pass. Then for each cell, use the precomputed values to skip the full scan. This cuts it to O(n^2).
How do I handle the 'not same column' constraint in DP?+
Store dp[i][j] as the minimum sum to reach row i, column j. When filling row i, for each column j, look at the minimum value from row i-1, but if that minimum is in column j, use the second-minimum instead. Precompute both in each row to avoid repeated scanning.
Is this problem still asked often at big companies?+
Roblox has confirmed asking it. It's a hard problem with solid acceptance, so it appears on interview rotations. It's not as common as easier DP problems, but it's common enough that you should know the second-minimum pattern before an OA.
What's the easiest way to mess this up?+
Forgetting to handle the second-minimum case correctly. If the best column in the previous row is j and you're at column j now, you must use the second-best from the previous row, not the best. Many candidates hard-code the minimum and break when they hit that edge case.
Want the actual problem statement? View "Minimum Falling Path Sum II" on LeetCode →