← 返回 jpmorgan 的题目列表Alphanumeric Vowel / Consonant Count
类型:qbank
Determine whether a string contains only letters and digits; if it does, count vowel and consonant letters.
Requirements
Input: a string.
First check whether every character is alphanumeric: letter or digit only.
If the string is valid, count vowels and consonant letters.
Digits are alphanumeric but are not vowels or consonants.
Return the counts in the format requested by the assessment.
Notes
Define vowels explicitly, usually a, e, i, o, u, case-insensitive.
Use character predicates carefully: underscore, whitespace, punctuation, and symbols should make the string non-alphanumeric.
Clarify output behavior for invalid strings before coding; the prompt title alone does not specify whether to return false, [-1, -1], or an error sentinel.
Preparation
Implement a case-insensitive scan with three branches: digit, vowel, consonant.
Test uppercase letters, digits-only strings, mixed alphanumeric strings, and strings with punctuation.