File tree Expand file tree Collapse file tree 2 files changed +23
-4
lines changed
Expand file tree Collapse file tree 2 files changed +23
-4
lines changed Original file line number Diff line number Diff line change 44
55### 성능 요약
66
7- 메모리: 63.9 MB, 시간: 13.97 ms
7+ 메모리: 63.7 MB, 시간: 14.54 ms
88
99### 구분
1010
1616
1717### 제출 일자
1818
19- 2025년 08월 30일 11:39:44
19+ 2025년 08월 30일 11:41:36
2020
2121### 문제 설명
2222
Original file line number Diff line number Diff line change 1+ import java .util .*;
12class Solution {
23 public int solution (int [][] triangle ) {
3- int answer = 0 ;
4- return answer ;
4+ int length = triangle .length ;
5+
6+ int [][] dp = new int [length ][length ];
7+ dp [0 ][0 ] = triangle [0 ][0 ];
8+ for (int i = 1 ; i < length ;i ++){
9+ int [] period = dp [i -1 ];
10+ for (int j = 0 ; j < i +1 ; j ++ ){
11+ int maxNum ;
12+ if (j == 0 ){
13+ maxNum = period [0 ];
14+ } else maxNum = Math .max (period [j -1 ] , period [j ]);
15+
16+ int current = triangle [i ][j ];
17+ dp [i ][j ] = maxNum + current ;
18+ }
19+ }
20+
21+ int [] lastDp = dp [length - 1 ];
22+ int max = Arrays .stream (lastDp ).max ().getAsInt ();
23+ return max ;
524 }
625}
You can’t perform that action at this time.
0 commit comments