Learn
Practice
Newsletter
Resources
Mobile
New
F
Toggle theme
0
F
0
Toggle menu
Animations
← 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
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
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
e
u
l
␣
s
k
y
␣
i
s
␣
b
e
h
t
left
right
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
e
u
l
b
␣
s
i
␣
y
k
s
␣
e
h
t
left
right
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
e
u
l
b
␣
s
i
␣
y
k
s
␣
e
h
t
i
write
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
b
l
u
e
␣
s
i
␣
y
k
s
␣
e
h
t
i
write
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
b
l
u
e
␣
s
i
␣
y
k
s
␣
e
h
t
i
write
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
b
l
u
e
␣
i
s
␣
y
k
s
␣
e
h
t
i
write
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
b
l
u
e
␣
i
s
␣
s
k
y
␣
e
h
t
i
write
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
b
l
u
e
␣
i
s
␣
s
k
y
␣
e
h
t
i
write
result = "blue is sky the"
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
b
l
u
e
␣
i
s
␣
s
k
y
␣
t
h
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
algo
master
.
io
Step:
Start: reverse the whole array, then reverse each word back into normal order