You are given a string s consisting of lowercase English words, each separated by a single space.
Determine how many vowels appear in the first word. Then, reverse each following word that has the same vowel count. Leave all remaining words unchanged.
Return the resulting string.
Vowels are 'a', 'e', 'i', 'o', and 'u'.
Example 1:
Input: s = "cat and mice"
Output: "cat dna mice"
Explanation:
"cat" has 1 vowel."and" has 1 vowel, so it is reversed to form "dna"."mice" has 2 vowels, so it remains unchanged."cat dna mice".Example 2:
Input: s = "book is nice"
Output: "book is ecin"
Explanation:
"book" has 2 vowels."is" has 1 vowel, so it remains unchanged."nice" has 2 vowels, so it is reversed to form "ecin"."book is ecin".Example 3:
Input: s = "banana healthy"
Output: "banana healthy"
Explanation:
"banana" has 3 vowels."healthy" has 2 vowels, so it remains unchanged."banana healthy".
Constraints:
1 <= s.length <= 105s consists of lowercase English letters and spaces.s are separated by a single space.s does not contain leading or trailing spaces.