← Visualizers
Basic Two Pointers LeetCode 344

Reverse String / visualized

Reverse a character array in place, O(1) extra space. Two pointers start at the ends and swap inward — no buffer, no StringBuilder, just index arithmetic.

Execution

idle
Press Run to begin.
0 / 0
Speed

Java · running line

pointers swapping locked in place
O(n) time · O(1) extra space  ·  exactly ⌊n/2⌋ swaps — the middle element of an odd-length string never moves.