Learn
Practice
Interview
Resources
Newsletter
F
Toggle theme
0
F
0
Toggle menu
Animations
← Back to All Animations
Decode String
Bookmark
Brute Force
Stack
Recursive
Input
Standard
Nested
Mixed
Custom
s
=
3[a]2[bc]
current string
3
[
a
]
2
[
b
c
]
find the innermost k[...] and expand it, repeat
current string
3
[
a
]
2
[
b
c
]
find the innermost k[...] and expand it, repeat
current string
3
[
a
]
2
[
b
c
]
innermost: 3[a]
current string
a
a
a
2
[
b
c
]
"a" × 3 spliced in
current string
a
a
a
2
[
b
c
]
innermost: 2[bc]
current string
a
a
a
b
c
b
c
"bc" × 2 spliced in
no brackets left
a
a
a
b
c
b
c
decoded = "aaabcbc"
algo
master
.
io
Step:
Repeatedly replace the innermost k[...] until no brackets remain.
0 / 5
Input
Standard
Nested
Mixed
Custom
s
=
3[a]2[bc]
0 / 5
algo
master
.
io
Step:
Repeatedly replace the innermost k[...] until no brackets remain.