Given a square integer matrix matrix of size n by n, return the minimum possible sum of a falling path through matrix.
A falling path starts at any element in the first row and chooses one element from each subsequent row. If the current element is at row r and column c, the next element must be in row r + 1 and in column c, c - 1, or c + 1, as long as the chosen column stays within the matrix bounds.
Constraints:
n == matrix.length == matrix[i].length
n
matrix[i][j]
Given a square integer matrix matrix of size n by n, return the minimum possible sum of a falling path through matrix.
A falling path starts at any element in the first row and chooses one element from each subsequent row. If the current element is at row r and column c, the next element must be in row r + 1 and in column c, c - 1, or c + 1, as long as the chosen column stays within the matrix bounds.
Constraints:
n == matrix.length == matrix[i].length
n
matrix[i][j]