DSA · Reimagined
Strings easy time O(n) space O(1)

Reverse a String

Swap the first and last characters, then move both pointers inward. In-place, no second string required.

a
0
l
1
g
2
o
3
r
4
i
5
t
6
h
7
m
8

Reverse "algorithm" in place.

1 / 9

Practice

Machine twin: /dsa-viz-v2/reverse-string.json — the full deterministic run as structured data.