Learn
Practice
Newsletter
Resources
Animations
New
F
Toggle theme
0
F
0
Toggle menu
← Back to All Animations
Reverse Words in a String
Bookmark
Input
Example 1
Example 2 (Spaces)
Example 3 (Multiple Spaces)
Single Word
Custom
s
=
the sky is blue
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
t
h
e
␣
s
k
y
␣
i
s
␣
b
l
u
e
algo
master
.
io
Step:
Start: reverse the whole array, then reverse each word back into normal order
0 / 38
Input
Example 1
Example 2 (Spaces)
Example 3 (Multiple Spaces)
Single Word
Custom
s
=
the sky is blue
0 / 38
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
t
h
e
␣
s
k
y
␣
i
s
␣
b
l
u
e
algo
master
.
io
Step:
Start: reverse the whole array, then reverse each word back into normal order