728x90
😉 아이디어
1. _!우측 하단 마름모를 차지할 경우 or 그렇지 않은 경우!_를 구분
2. 각 경우의 수에 맞게 배열에 값 저장
😉 풀이
def solution(n, tops):
a = [0] * (n + 1)
b = [0] * (n + 1)
if (tops[0]):
a[1] = 1
b[1] = 3
else:
a[1] = 1
b[1] = 2
MOD = 10_007
for i in range(2, n + 1):
a[i] = (a[i - 1] + b[i - 1]) % MOD
if (tops[i - 1]):
b[i] = (a[i - 1] * 2 + b[i - 1] * 3) % MOD
else:
b[i] = (a[i - 1] * 1 + b[i - 1] * 2) % MOD
return (a[n] + b[n]) % MOD
✔ 링크 : https://school.programmers.co.kr/learn/courses/30/lessons/258705