Given a triangle, find the minimum path sum from top to bottom. Each
step you may move to adjacent numbers on the row below.For example, given the following triangle
class Solution {
public:
int minimumTotal(vector<vector<int>>& triangle) {
vector<int> minium;
vector<int> temp;
int min;
minium.push_back(triangle[0][0]);
for(int i = 1;i<triangle.size();++i){
temp.clear();
for(int j = 0;j<triangle[i].size();++j){
cout<<triangle[i][j]<<endl;
if( j == 0){
temp.push_back(minium[j] + triangle[i][j]);
}else if( j == triangle[i].size() -1){
temp.push_back(minium[j-1] + triangle[i][j]);
}else{
temp.push_back((minium[j-1]<minium[j]?minium[j-1]:minium[j]) + triangle[i][j]);
}
}
minium.clear();
minium.assign(temp.begin(), temp.end());
}
min = minium[0];
for(int i = 0;i<minium.size();i++){
min = min < minium[i]?min:minium[i];
}
return min;
}
};