-
[2024 KAKAO WINTER INTERNSHIP] 산 모양 타일링코딩 테스트/Level 3 2024. 11. 21. 18:33반응형
https://school.programmers.co.kr/learn/courses/30/lessons/258705
def solution(n, tops): dp = [0] * (2 * n + 1) dp[0], dp[1] = 1, 2 if tops[0] == 0 else 3 for i in range(2, 2 * n + 1): if i % 2 == 1 and tops[i // 2] == 1: dp[i] = (dp[i - 1] * 2 + dp[i - 2]) % 10_007 else: dp[i] = (dp[i - 1] + dp[i - 2]) % 10_007 return dp[-1]
반응형