From 9e675c081a9a3d2fea270d86242303c887f7b9e4 Mon Sep 17 00:00:00 2001 From: Jinyoung Jeong <80400463+jyoung2419@users.noreply.github.com> Date: Sun, 13 Sep 2026 23:42:09 +0900 Subject: [PATCH] Implement solution for painting N x 3 grid problem --- ...Number of Ways to Paint N \303\227 3 Grid" | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 "leetcode3/\354\240\225\354\247\204\354\230\201/1411. Number of Ways to Paint N \303\227 3 Grid" diff --git "a/leetcode3/\354\240\225\354\247\204\354\230\201/1411. Number of Ways to Paint N \303\227 3 Grid" "b/leetcode3/\354\240\225\354\247\204\354\230\201/1411. Number of Ways to Paint N \303\227 3 Grid" new file mode 100644 index 00000000..bef31d2c --- /dev/null +++ "b/leetcode3/\354\240\225\354\247\204\354\230\201/1411. Number of Ways to Paint N \303\227 3 Grid" @@ -0,0 +1,20 @@ +/** + * @param {number} n + * @return {number} + */ +var numOfWays = function(n) { + const MOD = 1e9 + 7; + + let aba = 6; + let abc = 6; + + for (let i = 1; i < n; i++) { + const nextAba = (aba * 3 + abc * 2) % MOD; + const nextAbc = (aba * 2 + abc * 2) % MOD; + + aba = nextAba; + abc = nextAbc; + } + + return (aba + abc) % MOD; +};