uploaded at 2023. 1. 21. 오후 2:45:48

This commit is contained in:
rl544
2023-01-21 14:45:49 +09:00
parent 6ecc3b252d
commit ff8ca6a710
+15
View File
@@ -0,0 +1,15 @@
// [문제 링크]: https://school.programmers.co.kr/learn/courses/30/lessons/12900
class Solution {
public int solution(int n) {
int[] ans = new int[n+1];
for(int a = 0; a <= n; a++){
int tmp = 0;
if(a == 0) tmp = 1;
if(a >= 1) tmp += ans[a-1];
if(a >= 2) tmp += ans[a-2];
ans[a] = tmp%1000000007;
}
return ans[n];
}
}