Skip to content

Commit d893433

Browse files
committed
1411
1 parent 049e6fa commit d893433

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
'''
2+
a b a
3+
---
4+
aba = 3
5+
abc = 2
6+
7+
a b c
8+
---
9+
aba = 2
10+
abc = 2a
11+
12+
'''
13+
class Solution:
14+
def numOfWays(self, n: int) -> int:
15+
mod = 10 ** 9 + 7
16+
aba = 6
17+
abc = 6
18+
19+
for i in range(n-1):
20+
new_aba = 2 * abc + 3 * aba
21+
new_abc = 2 * abc + 2 * aba
22+
aba,abc = new_aba, new_abc
23+
24+
return (aba + abc) % mod

0 commit comments

Comments
 (0)