#3775

Reverse Words With Same Vowel Count

medium · 66.6% accepted · 54 likes · top 72%

two pointers · string · simulation

Description

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'.

Solution