The Reverse Vowels of a String interview question asks you to reverse only the vowels (a, e, i, o, u — both lowercase and uppercase) in a given string, while keeping all other characters in their original positions. The result is the same string with vowels in reversed order and consonants and non-letter characters untouched.
This problem is asked at Apple, Uber, Microsoft, Meta, Amazon, Oracle, Google, and Bloomberg as a clean application of the two-pointer technique with a character-type filter. It is the "reverse only specific characters" pattern — a variant of the basic reverse that appears in text transformation, data anonymization, and encoding systems. It tests whether candidates can apply two-pointer logic with a conditional skip.
The pattern is the two-pointer technique with vowel filtering. Convert the string to a list. Place left at 0 and right at the last index. While left < right: advance left until it points to a vowel, advance right until it points to a vowel, then swap and move both pointers inward. Use a vowel set {'a','e','i','o','u','A','E','I','O','U'} for O(1) lookup. Rejoin and return.
Input: "hEllow"
Vowels in order: E (index 1), o (index 4). Two pointers:
"holloEw" → wait, let's retrace: "hEllow".
"hollEw" — 'h','o','l','l','E','w'.Result: "hollEw".
Wait — "hEllow" → vowels are 'E'(1) and 'o'(4). Swap → "hollEw". Correct.
left pointer reaches or crosses right.For the Reverse Vowels of a String coding problem, the two-pointer string interview pattern is the approach. Build a vowel set first for fast O(1) lookup. Interviewers at Nvidia and USAA often ask follow-ups like "what if you reverse only consonants?" — the same two-pointer pattern applies with an isalpha() and not vowel condition. Demonstrating this generalization shows pattern fluency.