aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorterminaldweller <devi@terminaldweller.com>2024-01-12 02:39:44 +0000
committerterminaldweller <devi@terminaldweller.com>2024-01-12 02:39:44 +0000
commit935a8c04f2370204581cf27ad9e9e9c7dd998302 (patch)
tree2175c38ee5fceda010680b84057d181df395a4e5
parent2385 (diff)
downloadleetcode-935a8c04f2370204581cf27ad9e9e9c7dd998302.tar.gz
leetcode-935a8c04f2370204581cf27ad9e9e9c7dd998302.zip
1704
-rwxr-xr-x1704/main.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/1704/main.py b/1704/main.py
new file mode 100755
index 0000000..3fb2870
--- /dev/null
+++ b/1704/main.py
@@ -0,0 +1,30 @@
+#!/usr/bin/env python
+
+
+class Solution:
+ def halvesAreAlike(self, s: str) -> bool:
+ vowels = ["a", "e", "i", "o", "u", "A", "E", "I", "O", "U"]
+ length = len(s) // 2
+ first = 0
+ second = 0
+ for i in range(0, length):
+ if s[i] in vowels:
+ first += 1
+
+ if s[length + i] in vowels:
+ second += 1
+
+ if first == second:
+ return True
+ return False
+
+
+def main():
+ solution = Solution()
+ print(solution.halvesAreAlike("book"))
+ print(solution.halvesAreAlike("textbook"))
+ print(solution.halvesAreAlike("AbCdEfGh"))
+
+
+if __name__ == "__main__":
+ main()