We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 092245a + 9738462 commit 70607d4Copy full SHA for 70607d4
LiiNi-coder/202511/12 PGM 땅따먹기.md
@@ -0,0 +1,22 @@
1
+```java
2
+import java.util.*;
3
+class Solution {
4
+ int solution(int[][] land) {
5
+ int n = land.length;
6
+ for(int i=1; i<n; i++){
7
+ land[i][0] += Math.max(Math.max(land[i-1][1], land[i-1][2]), land[i-1][3]);
8
+ land[i][1] += Math.max(Math.max(land[i-1][0], land[i-1][2]), land[i-1][3]);
9
+ land[i][2] += Math.max(Math.max(land[i-1][0], land[i-1][1]), land[i-1][3]);
10
+ land[i][3] += Math.max(Math.max(land[i-1][0], land[i-1][1]), land[i-1][2]);
11
+ }
12
+ int last = n - 1;
13
+ int answer = -1;
14
+ for(int i = 0; i< 4; i++){
15
+ if(answer <= land[last][i])
16
+ answer = land[last][i];
17
18
+ return answer;
19
20
+}
21
+
22
+```
0 commit comments