Tap here to switch tabs
Problem
Submissions

Problem: Reverse Words With Same Vowel Count

med
30 min
Try to solve the Reverse Words With Same Vowel Count problem.

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

med
30 min
Try to solve the Reverse Words With Same Vowel Count problem.

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.