Minimum Falling Path Sum II
HardDynamic Programming2d dp
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
You are given an n x n integer matrix grid. Pick exactly one element from every row so that elements picked from **adjacent rows never share a column**.
Return the minimum possible sum of the picked elements. For a 1 x 1 grid the answer is its only value.
An O(n^3) DP works; try for O(n^2).
Examples
Input: grid = [[1,2,3],[4,5,6],[7,8,9]]
Output: 13
Pick 1 (col 0), 5 (col 1), 7 (col 0): 1 + 5 + 7 = 13.
Input: grid = [[7]]
Output: 7
A single cell is the whole path.
Constraints
- n == grid.length == grid[i].length
- 1 <= n <= 200
- -99 <= grid[i][j] <= 99
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.