2025-08-22 17:20:58 +0000 UTC

Valid Word

Code

class Solution:
    def isValid(self, word: str) -> bool:
        vws = ('a', 'e', 'i', 'o', 'u')
        if len(word) < 3:
            return False
        has_vw, has_cons = False, False
        for i in range(len(word)):
            ch = word[i]
            if ch.isalpha():
                if ch.lower() in vws:
                    has_vw = True
                else:
                    has_cons = True
            elif not ch.isdigit():
                return False
        return has_vw and has_cons