← Visualizers
Opposite-Ends Two Pointers LeetCode 345

Reverse Vowels of a String / visualized

Reverse only the vowels, leaving every consonant exactly where it is. Same converging two-pointer shape as Reverse String, but each side first skips forward past anything that isn't a vowel.

Execution

idle
Press Run to begin.
0 / 0
Speed

Java · running line

pointers on a vowel swapping done consonant (untouched)
O(n) time · O(1) extra space (excluding the output string)  ·  consonants never move — only their positions get skipped over.