JuniorString

Valid Word

A word is considered valid if:

  • It contains a minimum of 3 characters.
  • It contains only digits (0-9) and English letters, both 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.

Notes:

  • 'a', 'e', 'i', 'o', 'u', and their uppercase forms are vowels.
  • A consonant is an English letter that is not a vowel.
Example 1
Inputword = "234Adas"
Outputtrue
This word satisfies all the conditions.
Example 2
Inputword = "b3"
Outputfalse
The length of this word is fewer than 3, and it does not have a vowel.

Constraints

  • 1 <= word.length <= 20
  • word consists of English uppercase and lowercase letters, digits, '@', '#', and '$'.

Asked at 8 companies

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate