Skip to content

Commit

Permalink
정수 삼각형 - level3
Browse files Browse the repository at this point in the history
  • Loading branch information
sey2 authored Aug 25, 2022
1 parent cb95fa2 commit a5e4710
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions programmers/IntegerTriangle.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class Solution {
public int solution(int[][] triangle) {

for(int i=triangle.length-2; i>=0; i--){
for(int j=0; j< triangle[i].length; j++){
int sum1 = triangle[i+1][j] + triangle[i][j];
int sum2 = triangle[i+1][j+1] + triangle[i][j];

triangle[i][j] = Math.max(sum1,sum2);
}
}

return triangle[0][0];
}
}

0 comments on commit a5e4710

Please sign in to comment.