Tap here to switch tabs
Problem
Ask
Submissions

Problem: Reverse Vowels of a String

med
30 min
Explore how to reverse only the vowels in a given string using the two pointers pattern. This lesson helps you understand vowel identification and string traversal to implement an efficient solution within linear time constraints.

Statement

Given a string s, reverse only the vowels in the string and return the resulting string.

The vowels are ‘a’, ‘e’, ‘i’, ‘o’, and ‘u’, and they can appear in both lowercase and uppercase, potentially more than once.

Constraints:

  • 1 ≤ s.length ≤ 3 × 105

  • s consists of printable ASCII characters.

Tap here to switch tabs
Problem
Ask
Submissions

Problem: Reverse Vowels of a String

med
30 min
Explore how to reverse only the vowels in a given string using the two pointers pattern. This lesson helps you understand vowel identification and string traversal to implement an efficient solution within linear time constraints.

Statement

Given a string s, reverse only the vowels in the string and return the resulting string.

The vowels are ‘a’, ‘e’, ‘i’, ‘o’, and ‘u’, and they can appear in both lowercase and uppercase, potentially more than once.

Constraints:

  • 1 ≤ s.length ≤ 3 × 105

  • s consists of printable ASCII characters.