Valid Word - Problem
A word is considered valid if it satisfies the following conditions:
- It contains a minimum of 3 characters
- It contains only digits (0-9) and English letters (uppercase and lowercase)
- It includes at least one vowel
- It includes at least one consonant
You are given a string word. Return true if word is valid, otherwise return false.
Note: 'a', 'e', 'i', 'o', 'u' and their uppercases are vowels. A consonant is an English letter that is not a vowel.
Input & Output
Example 1 — Valid Word
$
Input:
word = "UuE6"
›
Output:
false
💡 Note:
Length is 4 (≥3), contains only alphanumeric characters, has vowels 'U', 'u', 'E' but no consonants, so returns false.
Example 2 — Invalid Word (No Consonant)
$
Input:
word = "aeiou"
›
Output:
false
💡 Note:
Has vowels but no consonants, so it's invalid.
Example 3 — Valid Mixed Word
$
Input:
word = "a1B"
›
Output:
true
💡 Note:
Length is 3, has vowel 'a', consonant 'B', and digit '1' - all conditions satisfied.
Constraints
- 1 ≤ word.length ≤ 20
- word consists of English letters, digits, and special characters
Visualization
Tap to expand
💡
Explanation
AI Ready
💡 Suggestion
Tab
to accept
Esc
to dismiss
// Output will appear here after running code