left pointer
Scans rightward from the start, skipping every consonant until it finds a vowel or meets the right pointer.
A typographer mirrors only the vowel glyphs in a display string while leaving consonants fixed — reflecting 'hello' to 'holle'. Two pointers converge from opposite ends, each skipping consonants. Only when both land on a vowel do they swap. The consonant skeleton stays intact while the vowels reflect across it. O(n) time. O(n) space for the character array.
The left pointer only advances past consonants; the right pointer only retreats past consonants. A swap happens exactly when both pointers sit on vowels — guaranteeing every vowel finds its mirror partner.
Scans rightward from the start, skipping every consonant until it finds a vowel or meets the right pointer.
Scans leftward from the end, skipping every consonant until it finds a vowel or meets the left pointer.
When both pointers rest on vowels, the characters swap. Both pointers then step inward and the search continues.
Strings are immutable, so copy the characters into a mutable array to allow in-place swaps.
Set left = 0 and right = length − 1. They will walk toward each other.
While left < right: skip left if it's a consonant, skip right if it's a consonant, otherwise swap both characters and advance both pointers inward.
Join the modified char array back into a string. All vowels are now reversed; consonants remain in place.
Both pointers race past consonants until they cross. No swap ever occurs — the string returns unchanged. The algorithm gracefully handles consonant-only inputs like "rhythm."
Every character is a vowel, so neither pointer ever skips. The string fully reverses — identical to reversing the whole string. The algorithm performs ⌊n/2⌋ swaps.
When the vowel sequence reads the same forwards and backwards, swaps still happen but produce the same characters. The output equals the input — e.g., "racecar" stays "racecar."