aboutsummaryrefslogtreecommitdiff
path: root/ways_to_paint_nx3_grid.cpp
diff options
context:
space:
mode:
authorjack <[email protected]>2024-06-14 13:13:15 -0600
committerjack <[email protected]>2024-06-14 13:13:15 -0600
commitd343a3b18dbaca9297d4f7b2280c4a16f0a5c8aa (patch)
tree96df922dae2a5073d9a50ea70c7aae6aa37e3ebe /ways_to_paint_nx3_grid.cpp
downloadleetcode-d343a3b18dbaca9297d4f7b2280c4a16f0a5c8aa.tar.gz
leetcode-d343a3b18dbaca9297d4f7b2280c4a16f0a5c8aa.zip
initial
Diffstat (limited to 'ways_to_paint_nx3_grid.cpp')
-rw-r--r--ways_to_paint_nx3_grid.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/ways_to_paint_nx3_grid.cpp b/ways_to_paint_nx3_grid.cpp
new file mode 100644
index 0000000..b661af8
--- /dev/null
+++ b/ways_to_paint_nx3_grid.cpp
@@ -0,0 +1,20 @@
+#include "leetcode.h"
+
+class Solution {
+public:
+ int numOfWays(int n) {
+ long a = 6, b = 6, c, d, mod = 1e9 + 7;
+ for (int i = 1; i < n; ++i) {
+ c = a * 3 + b * 2;
+ d = a * 2 + b * 2;
+ a = c % mod;
+ b = d % mod;
+ }
+ return (a + b) % mod;
+ }
+};
+
+int main() {
+ Solution obj;
+ cout << obj.numOfWays(1);
+}