Logo
IconChallenge
Icon
IconProblem
IconSolutions
IconSubmissions

Valid Word

XPChallenge Points: 10
levelLevel: Easy

A word is considered valid if:

  1. Its length is at least 3.

  2. It contains only English letters (a-z, A-Z) or digits (0-9).

  3. It has at least one vowel.

  4. It has at least one consonant.

You are given a string word.
Return true if the word follows all rules, otherwise return false.

Vowels are: a, e, i, o, u (both lowercase and uppercase).
A consonant is any other English letter.

Example 1:

Input: word = "Hello3"

Output: true

Explanation:

Contains vowels (e,o), consonants (h,l,l), and has valid characters only.

Example 2:

Input: word = "AEI9"

Output: false

Explanation:

It has vowels but no consonant.

Example 3:

Input: word = "xyz"

Output: false

Explanation:

Contains consonants but missing a vowel.

to Continue
like
dislike

Accepted:

Submission:

IconReport an issue
Icon
IconCode
IconYou need toto run or submitYou need toto run or submit
IconTest Case
IconTest Result