Tap here to switch tabs
Problem
Submissions

Problem: Reverse Words With Same Vowel Count

Reverse Words With Same Vowel Count gives you a space-separated string. Return it with each later word whose count of a, e, i, o, and u matches the first word reversed, leaving the first word unchanged.

Statement

You are given a string s consisting of words separated by a single space.

Determine the number of vowels in the first word of s, where vowels are defined as 'a', 'e', 'i', 'o', and 'u'. For each subsequent word in s, if its vowel count equals the vowel count of the first word, reverse the characters of that word. The first word itself remains unchanged.

Return the modified string.

Constraints:

  • 1≤1 \leq s.length ≤105\leq 10^5

  • s consists of lowercase English letters and spaces.

  • Words in s are separated by a single space.

  • s does not contain leading or trailing spaces.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Reverse Words With Same Vowel Count

Reverse Words With Same Vowel Count gives you a space-separated string. Return it with each later word whose count of a, e, i, o, and u matches the first word reversed, leaving the first word unchanged.

Statement

You are given a string s consisting of words separated by a single space.

Determine the number of vowels in the first word of s, where vowels are defined as 'a', 'e', 'i', 'o', and 'u'. For each subsequent word in s, if its vowel count equals the vowel count of the first word, reverse the characters of that word. The first word itself remains unchanged.

Return the modified string.

Constraints:

  • 1≤1 \leq s.length ≤105\leq 10^5

  • s consists of lowercase English letters and spaces.

  • Words in s are separated by a single space.

  • s does not contain leading or trailing spaces.