2 parents 4fad66a + 9e675c0 commit 3e4a353Copy full SHA for 3e4a353
1 file changed
leetcode3/정진영/1411. Number of Ways to Paint N × 3 Grid
@@ -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