Skip to content

Commit dd26705

Browse files
authored
[20251026] PGM / LV2 / 멀리 뛰기 / 이인희
1 parent cfd71e4 commit dd26705

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
```java
2+
class Solution {
3+
private static long[] dp;
4+
public long solution(int n) {
5+
dp = new long[n + 1];
6+
dp[1] = 1;
7+
if (n >= 2)
8+
dp[2] = 2;
9+
return getDp(n);
10+
}
11+
12+
private long getDp(int n) {
13+
if (dp[n] != 0) return dp[n];
14+
dp[n] = (getDp(n - 1) + getDp(n - 2)) % 1234567;
15+
return dp[n];
16+
}
17+
}
18+
19+
```

0 commit comments

Comments
 (0)