mirror of https://github.com/doocs/leetcode.git
12 lines
436 B
Java
12 lines
436 B
Java
class Solution {
|
|
public int minimumTotal(List<List<Integer>> triangle) {
|
|
for (int i = triangle.size() - 2; i >= 0; --i) {
|
|
for (int j = 0; j <= i; ++j) {
|
|
int x = triangle.get(i).get(j);
|
|
int y = Math.min(triangle.get(i + 1).get(j), triangle.get(i + 1).get(j + 1));
|
|
triangle.get(i).set(j, x + y);
|
|
}
|
|
}
|
|
return triangle.get(0).get(0);
|
|
}
|
|
} |