aboutsummaryrefslogtreecommitdiffstats
path: root/1220
diff options
context:
space:
mode:
authorterminaldweller <thabogre@gmail.com>2022-08-07 04:27:12 +0000
committerterminaldweller <thabogre@gmail.com>2022-08-07 04:27:12 +0000
commit3333839302c05245b35c23241d8d22ef495ba800 (patch)
tree01ee15692f887b8b462981cfaf2a923b7cb3f831 /1220
parentupdate (diff)
downloadleetcode-3333839302c05245b35c23241d8d22ef495ba800.tar.gz
leetcode-3333839302c05245b35c23241d8d22ef495ba800.zip
update
Diffstat (limited to '1220')
-rwxr-xr-x1220/main.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/1220/main.py b/1220/main.py
new file mode 100755
index 0000000..8d6b919
--- /dev/null
+++ b/1220/main.py
@@ -0,0 +1,31 @@
+#!/usr/bin/env python3
+# not my solution
+
+
+class Solution:
+ def countVowelPermutation(self, n: int) -> int:
+ kMod = int(1e9) + 7
+ dp = {"a": 1, "e": 1, "i": 1, "o": 1, "u": 1}
+
+ for _ in range(n - 1):
+ newDp = {
+ "a": dp["e"] + dp["i"] + dp["u"],
+ "e": dp["a"] + dp["i"],
+ "i": dp["e"] + dp["o"],
+ "o": dp["i"],
+ "u": dp["i"] + dp["o"],
+ }
+ dp = newDp
+
+ return sum(dp.values()) % kMod
+
+
+def main():
+ solution = Solution()
+ print(solution.countVowelPermutation(1))
+ print(solution.countVowelPermutation(2))
+ print(solution.countVowelPermutation(5))
+
+
+if __name__ == "__main__":
+ main()