Skip to content

Commit

Permalink
leetcode valid word
Browse files Browse the repository at this point in the history
  • Loading branch information
ferhatelmas committed May 6, 2024
1 parent 96dead6 commit b9bb4eb
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions leetcode/algorithms/easy/valid_word.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from string import ascii_lowercase, digits


class Solution:
def isValid(self, word: str) -> bool:
v, c = False, False
for e in word.lower():
if e not in ascii_lowercase and e not in digits:
return False

if not v and e in "aeiou":
v = True
continue

if not c and e in ascii_lowercase and e not in "aeiou":
c = True
continue

return v and c and len(word) >= 3


print(Solution().isValid("234Adas"))

0 comments on commit b9bb4eb

Please sign in to comment.