class Solution { public: vector > *t; // I make this a pointer so that I'm not making a copy of triangle. int minimumTotal(vector>& triangle); int dp(int row, int col); }; int Solution::minimumTotal(vector>& triangle) { size_t i; t = ▵ return dp(0, 0); } /* Here is a straightforward implementation of the recursive solution. */ int Solution::dp(int row, int col) { int z, o, answer; /* Base case is when we're at the last row of the triangle. */ if (row == t->size()-1) return (*t)[row][col]; /* Otherwise, we make the two recursive calls and add the minimum to our triangle entry. */ z = dp(row+1, col); o = dp(row+1, col+1); answer = (*t)[row][col] + ((z < o) ? z : o); return answer; }