[ํ๋ก๊ทธ๋๋จธ์ค] LV.2 ๋ฉ๋ฆฌ ๋ฐ๊ธฐ (์๋ฐ java)
1. ๋ฌธ์ : https://school.programmers.co.kr/learn/courses/30/lessons/12914
2. ํ์ด
dp๋ก ๋ฐฐ์ด์ ์ ์ฅํ๋ฉด์ ํ์ด์ผ ํจ์จ์ด ๋์ค๋ ๋ฌธ์
๊ธฐ๋ณธ ๊ฐ๋ ์ ํผ๋ณด๋์น ์์ด์ด๋ค.
3. ์ฝ๋
class Solution {
public long solution(int n) {
int[] dp = new int[2001];
dp[1] = 1;
dp[2] = 2;
for(int i=3; i<2001; i++){
dp[i] = (dp[i-2] + dp[i-1]) % 1234567;
}
return dp[n];
}
}
'๐ป Coding Problems Solving > Dynamic Programming' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[ํ๋ก๊ทธ๋๋จธ์ค] LV.2 2*n ํ์ผ๋ง (์๋ฐ java) (0) | 2023.03.15 |
---|---|
[ํ๋ก๊ทธ๋๋จธ์ค] LV.2 ๋ ๋ฐ๋จน๊ธฐ (์๋ฐ java) (0) | 2023.03.10 |
[LeetCode] Maximum Subarray (0) | 2022.07.24 |
[LeetCode] Climbing Stairs (0) | 2022.07.09 |
[BOJ 15486] ํด์ฌ2 (0) | 2022.07.05 |
์ต๊ทผ๋๊ธ