Notice
Recent Posts
Recent Comments
Link
«   2024/07   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31
Archives
Today
Total
관리 메뉴

csct3434

[level 2] 3 x n 타일링 - 12902 본문

프로그래머스

[level 2] 3 x n 타일링 - 12902

csct3434 2024. 2. 28. 19:43
class Solution {

    public int solution(int n) {
       long[] dp = new long[n + 1];
       dp[2] = 3L;
       dp[4] = 11L;

       for (int i = 6; i <= n; i += 2) {
          dp[i] = ((((4 * dp[i - 2]) % 1000000007) - ((dp[i - 4]) % 1000000007)) + 1000000007) % 1000000007;
       }

       return (int) dp[n];
    }
}