Algorithm : DP;
public class Solution
{
public int
minimumTotal(ArrayList<ArrayList<Integer>> triangle)
{
for(int i
= triangle.size()-2; i>=0;i--)
{
ArrayList<Integer> a1 =
triangle.get(i);
ArrayList<Integer> nextLevel =
triangle.get(i+1);
for(int j = 0;
j<a1.size();j++)
{
int
sum2=0,sum3=0;
sum2 = a1.get(j) +
nextLevel.get(j);
sum3 = a1.get(j) +
nextLevel.get(j+1);
a1.set(j,
Math.min(sum2,sum3));
}
}
return
triangle.get(0).get(0);
}
}