https://school.programmers.co.kr/learn/courses/30/lessons/43105?language=java
3가지의 경우가 존재한다.
이를 기록해가며 진행하면 된다.
class Solution {
public int solution(int[][] triangle) {
int answer = 0;
for(int i=1;i<triangle.length;i++){
for(int j=0;j<triangle[i].length;j++){
if(j == 0){
triangle[i][0] += triangle[i-1][0];
} else if(j == i){
triangle[i][i] += triangle[i-1][i-1];
} else{
triangle[i][j] += Math.max(triangle[i-1][j-1], triangle[i-1][j]);
}
}
}
for(int i=0;i<triangle.length;i++){
if(answer < triangle[triangle.length - 1][i]){
answer = triangle[triangle.length - 1][i];
}
}
return answer;
}
}