Skip to content

Commit 3e4a353

Browse files
Merge pull request #2022 from CodingTestStudy2/정진영
[정진영] Day13
2 parents 4fad66a + 9e675c0 commit 3e4a353

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* @param {number} n
3+
* @return {number}
4+
*/
5+
var numOfWays = function(n) {
6+
const MOD = 1e9 + 7;
7+
8+
let aba = 6;
9+
let abc = 6;
10+
11+
for (let i = 1; i < n; i++) {
12+
const nextAba = (aba * 3 + abc * 2) % MOD;
13+
const nextAbc = (aba * 2 + abc * 2) % MOD;
14+
15+
aba = nextAba;
16+
abc = nextAbc;
17+
}
18+
19+
return (aba + abc) % MOD;
20+
};

0 commit comments

Comments
 (0)