5 line solution bottom-up DP !!


  • 0
    R
     int minimumTotal(vector<vector<int>>& a) {
        if(a.empty())return 0;
        for(int i = a.size()-2; i >= 0; i--){
            for(int j = 0; j < i+1; j++){
                 a[i][j] = min(a[i+1][j],a[i+1][j+1]) + a[i][j]; }  }
        return a[0][0];
    }

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.