```
int minimumTotal(vector<vector<int>>& triangle)
{
for (int i = 1; i != triangle.size(); ++i){
auto& lastRow = triangle[i - 1];
auto& currentRow = triangle[i];
currentRow[0] += lastRow[0];
currentRow[i] += lastRow[i - 1];
for (int j = 1; j != i; ++j){
currentRow[j] += min(lastRow[j - 1], lastRow[j]);
}
}
return *min_element(triangle.back().cbegin(),
triangle.back().cend());
}
```