Count Vowels, Consonants, Digits, and Spaces
Given one string s containing printable ASCII characters, return four counts in this order: vowels, consonants, digits, and spaces. Count A, E, I, O, and U as…
Given one string `s` containing printable ASCII characters, return four counts in this order: vowels, consonants, digits, and spaces. Count `A`, `E`, `I`, `O`, and `U` as vowels without regard to case. Count every other English letter, including `Y`, as a consonant. Count digits from `0` through `9` and only the ordinary space character. Ignore punctuation and symbols. For example, `"AaE!bB 09"` contains three vowels, two consonants, two digits, and one space, so the result is `[3, 2, 2, 1]`.
- `0 <= s.length <= 100000` - Every character is printable ASCII from U+0020 through U+007E. - Vowels are `A`, `E`, `I`, `O`, and `U`, matched case-insensitively. - Every other ASCII letter is a consonant, including `Y` and `y`. - Only digits `0` through `9` are counted as digits. - Only U+0020 (`' '`) is counted as a space; punctuation and symbols are ignored. - Return a native ordered array of exactly four integers: `[vowels, consonants, digits, spaces]`. - The visualizer accepts strings of length `0` through `40`; longer valid strings remain coding inputs.
Example 1: input s = "AaE!bB 09"; output [3, 2, 2, 1]. The input has three vowels, two consonants, two digits, and one ordinary space.
Example 2: input s = "AEIOUxyY"; output [5, 3, 0, 0]. All five vowels count, and x, y, and Y are consonants.
Example 3: input s = " !? 09"; output [0, 0, 2, 3]. The two digits and three spaces count; punctuation is ignored.
Category: Strings. Topic: strings. Difficulty: Easy. Patterns: string-processing.