Number of Ways to Paint N × 3 Grid LeetCode solution in Python

1
class Solution:
2
def numOfWays(self, n: int) -> int:
3
two_c_options = 6
4
tot_options = 12
5
for i in range(n - 1):
6
temp = tot_options
7
tot_options = (two_c_options * 5) + ((tot_options - two_c_options) * 4)
8
two_c_options = (two_c_options * 3) + ((temp - two_c_options) * 2)
9
tot_options = tot_options % (1000000007)
10
return tot_options

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0