Best and understandable soln C++


#1

int Solution::solve(vector<vector > &B) {

vector<vector<int>>A=B;
for(int i=1;i<A.size();i++){
    A[i][0]+= min(A[i-1][1],A[i-1][2]);
    A[i][1]+= min(A[i-1][2],A[i-1][0]);
    A[i][2]+= min(A[i-1][1],A[i-1][0]);
}
return min(A[A.size()-1][0],min(A[A.size()-1][1],A[A.size()-1][2]));

}