Given n x n integer matrix, return the minimum sum of any falling path through the matrix. A falling path starts at any element in the first row and chooses the element in the next row that is directly below or diagonally adjacent.
DP: for each cell (i,j), the minimum falling path is min of the three cells above it (i-1, j-1), (i-1, j), (i-1, j+1) plus matrix[i][j].
- Process row by row in-place.
- For each row i from 1 to n-1:
- For each col j: matrix[i][j] += min(matrix[i-1][j], matrix[i-1][j-1 if valid], matrix[i-1][j+1 if valid]).
- Return min of last row.
- Time Complexity: O(N^2)
- Space Complexity: O(1)