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: true
💡 Note: Length is 4 (≥3), contains only alphanumeric characters, has vowels 'U', 'u', 'E' and no consonants, so returns false. Wait - let me recalculate: 'U', 'u', 'E' are vowels but there's no consonant, so this should be 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
Valid Word Problem OverviewInput: "a1B"String to validateValidation Rules✓ Length ≥ 3✓ Alphanumeric only✓ Has vowel✓ Has consonantOutput: trueAll conditions meta1BvoweldigitconsonantCharacter Analysis: Length=3, Has vowel 'a', Has consonant 'B'
Understanding the Visualization
1
Input
String word to validate
2
Validate
Check length, characters, vowels, consonants
3
Output
Boolean result
Key Takeaway
🎯 Key Insight: Single pass validation checking all four conditions simultaneously
Asked in
Google 15 Microsoft 12
12.0K Views
Medium Frequency
~15 min Avg. Time
450 Likes
Ln 1, Col 1
Smart Actions
💡 Explanation
AI Ready
💡 Suggestion Tab to accept Esc to dismiss
// Output will appear here after running code
Code Editor Closed
Click the red button to reopen