Skip to content

Commit

Permalink
멀리 뛰기 - level2
Browse files Browse the repository at this point in the history
  • Loading branch information
sey2 authored Aug 29, 2022
1 parent 3a3ed13 commit a50f3f7
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions programmers/LongJump.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class Solution {
public long solution(int n) {
long dp[] = new long[20001];
dp[1] = 1; dp[2]=2; dp[3]=3;

if(n<=3) return dp[n];

for(int i=4; i<=n; i++)
dp[i] = (dp[i-2] + dp[i-1]) % 1234567;

return dp[n];
}
}

0 comments on commit a50f3f7

Please sign in to comment.