# 931. Minimum Falling Path Sum

[Link](https://leetcode.com/problems/minimum-falling-path-sum/)

#### Solution

```java
 public int minFallingPathSum(int[][] A) {
        int N = A.length;
        if(N == 1) return A[0][0];
        int rest = Integer.MAX_VALUE;
        for(int i = N-2; i >= 0; i--){
            
            for(int j = 0; j < N; j++){
                A[i][j] += Math.min(A[i+1][j], 
                                    Math.min(
                                        j-1 >= 0 ? A[i+1][j-1] : 101,
                                        j+1 < N ? A[i+1][j+1] : 101));
                
                if( i == 0 ){
                    rest = Math.min(rest, A[i][j]);
                }
            }
        }
        return rest;
    }
```
