Reverse Only Vowel Occurrences in an ASCII String

Quick Overview

Reverse Only Vowel Occurrences in an ASCII String. Reverse the sequence of vowels in s while leaving every nonvowel position unchanged. Vowels are a,e,i,o,u in either case; move each vowel's actual character, pr

Reverse Only Vowel Occurrences in an ASCII String

Company: Google

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: easy

Interview Round: Other

### Problem Reverse the sequence of vowels in s while leaving every nonvowel position unchanged. Vowels are a,e,i,o,u in either case; move each vowel's actual character, preserving its case. ```cpp string reverseVowels(string s); ``` ### Examples ```text s = "a-bE" -> "E-ba" s = "rhythm!" -> "rhythm!" ``` ### Constraints - String length is 1 through 300000. - Characters are printable ASCII.

Overview: Reverse Only Vowel Occurrences in an ASCII String. Reverse the sequence of vowels in s while leaving every nonvowel position unchanged. Vowels are a,e,i,o,u in either case; move each vowel's actual character, pr

Google logo
Google
Source window: 0–3 months · as of Oct 21, 2026
easySoftware EngineerOtherCoding & Algorithms
0
0

Problem

Reverse the sequence of vowels in s while leaving every nonvowel position unchanged. Vowels are a,e,i,o,u in either case; move each vowel's actual character, preserving its case.

string reverseVowels(string s);

Examples

s = "a-bE" -> "E-ba"
s = "rhythm!" -> "rhythm!"

Constraints

  • String length is 1 through 300000.
  • Characters are printable ASCII.