aboutsummaryrefslogtreecommitdiff
path: root/other/domino_tromino_tiling.cpp
diff options
context:
space:
mode:
authorJack Sangdahl <[email protected]>2025-03-10 00:36:13 -0600
committerJack Sangdahl <[email protected]>2025-03-10 00:36:13 -0600
commit7c60dee83b436e8e8a667bf9f191beced8de4fc3 (patch)
treeeb7a24ee2067f92245c57bb118e85a1baf15df50 /other/domino_tromino_tiling.cpp
parent5d7cdc215e4ba1ec4cbb24c084cccb5e5e641468 (diff)
downloadleetcode-7c60dee83b436e8e8a667bf9f191beced8de4fc3.tar.gz
leetcode-7c60dee83b436e8e8a667bf9f191beced8de4fc3.zip
chore: move cpp and rust code to directory
Diffstat (limited to 'other/domino_tromino_tiling.cpp')
-rw-r--r--other/domino_tromino_tiling.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/other/domino_tromino_tiling.cpp b/other/domino_tromino_tiling.cpp
new file mode 100644
index 0000000..80a97d0
--- /dev/null
+++ b/other/domino_tromino_tiling.cpp
@@ -0,0 +1,28 @@
+#include "leetcode.h"
+#include <vector>
+
+class Solution {
+public:
+ int numTilings(int n) {
+ int mod = 1e9;
+ mod += 7;
+ vector<long long> ans(1001, 0);
+ ans[1] = 1;
+ ans[2] = 2;
+ ans[3] = 5;
+ if (n <= 3)
+ return ans[n];
+ for (int i = 4; i <= n; ++i) {
+ ans[i] = 2 * ans[i - 1] + ans[i - 3];
+ ans[i] %= mod;
+ }
+ return ans[n];
+ }
+};
+
+int main() {
+ Solution obj;
+ cout << obj.numTilings(3); // 5
+ cout << endl;
+ cout << obj.numTilings(1); // 1
+}