Reported September 2026
Googletwo pointers

Reverse Vowels of a String

Reported by candidates from Google's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Google OA. Under 2s to a working solution.
Founder's read

Google flagged this one in September 2026, and it looks easy until a single edge case wrecks a naive solution. Reverse Vowels of a String is a two-pointers problem. You swap vowels from both ends while consonants stay put. The catch is mixed case, empty strings, and a length up to 10^6 that punishes lazy string rebuilding. If you're taking this OA in the next day or two, you need the pattern cold and a hedge for when your mind goes blank. StealthCoder is that hedge, running invisibly during the live assessment.

The problem

Given a string s, reverse only its vowel characters and return the resulting string.
The vowels are a, e, i, o, and u, in either lowercase or uppercase. Preserve every vowel's original character and case while reversing their order. Every non-vowel character remains at its original index.
The string may be large, so avoid repeated string rebuilding that takes quadratic time.

Function
reverseVowels(s: String) → String

Examples
Example 1
s = "hello"
return = "holle"
The vowels are e and o. Reversing them produces holle.
Example 2
s = "leetcode"
return = "leotcede"
The vowel sequence e, e, o, e becomes e, o, e, e; consonants keep their positions.
Example 3
s = "aA"
return = "Aa"
Uppercase and lowercase vowels both participate, and their original cases move with the characters.

Constraints
0 <= s.length <= 10^6.
s contains printable ASCII characters.

Reported by candidates. Source: FastPrep

Pattern and pitfall

Convert the string to a character array, put a left pointer at 0 and a right pointer at the end. Move left forward until it hits a vowel. Move right backward until it hits a vowel. Swap them, step both, repeat while left < right. Use a set containing a, e, i, o, u and their uppercase forms so case is preserved automatically, since you move the actual characters. The pitfall is building the result with repeated string concatenation, which goes quadratic at 10^6 characters. Another trap is forgetting uppercase vowels, so "aA" fails. Empty strings and strings with no vowels should just return as is. The whole thing runs in O(n) time. If you freeze on the pointer loop conditions during the live OA, StealthCoder can give you the working solution without the proctor seeing it.

If this hits your live OA and you blank, StealthCoder solves it in seconds, invisible to the proctor.

If this hits your live OA

You can drill Reverse Vowels of a String cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it.

Get StealthCoder

Related leaked OAs

⏵ Practice the LeetCode equivalent

This OA pattern shows up on LeetCode as reverse vowels of a string. If you have time before the OA, drill that.

⏵ The honest play

You've seen the question. Make sure you actually pass Google's OA.

Google reuses patterns across OAs. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Reverse Vowels of a String FAQ

What's the trick to Reverse Vowels of a String?+

Two pointers from opposite ends. Skip non-vowels on each side, swap when both point at vowels, then move inward. Work on a character array, not a string, so each swap is O(1). Total time is O(n) with one pass.

What edge case breaks the naive solution here?+

Uppercase vowels. If your vowel check only covers lowercase, "aA" returns the wrong answer. Include both cases in your vowel set. Also handle the empty string and strings with no vowels, which should return unchanged.

Will the 10^6 length limit matter?+

Yes. Concatenating strings in a loop can go quadratic and time out. Convert to a mutable array, swap in place, then join once at the end. That keeps you at linear time and avoids the performance trap.

Is the two-pointers pattern still asked at Google?+

It showed up in a September 2026 report, so yes. Two pointers on strings and arrays remains a common OA pattern because it's short to write but easy to get subtly wrong under pressure.

How do I prepare for this in 48 hours?+

Write the solution from scratch twice, once with a vowel set and once with a helper function. Test with "hello", "leetcode", "aA", an empty string, and a string of only consonants. Related problems like reverse string and valid palindrome use the same loop.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Google.

OA at Google?
Invisible during screen share
Get it