diff --git "a/leetcode3/\353\263\200\354\247\200\355\230\221/v3/1411. Number of Ways to Paint N \303\227 3 Grid.py" "b/leetcode3/\353\263\200\354\247\200\355\230\221/v3/1411. Number of Ways to Paint N \303\227 3 Grid.py" new file mode 100644 index 00000000..2f797eb1 --- /dev/null +++ "b/leetcode3/\353\263\200\354\247\200\355\230\221/v3/1411. Number of Ways to Paint N \303\227 3 Grid.py" @@ -0,0 +1,24 @@ +''' +a b a +--- +aba = 3 +abc = 2 + +a b c +--- +aba = 2 +abc = 2a + +''' +class Solution: + def numOfWays(self, n: int) -> int: + mod = 10 ** 9 + 7 + aba = 6 + abc = 6 + + for i in range(n-1): + new_aba = 2 * abc + 3 * aba + new_abc = 2 * abc + 2 * aba + aba,abc = new_aba, new_abc + + return (aba + abc) % mod