Learn
Practice
Interview
Resources
Newsletter
F
Toggle theme
0
F
0
Toggle menu
Animations
← Back to All Animations
Remove Duplicate Letters
Bookmark
Brute Force
Greedy Stack
Input
Example 1
Example 2
Example 3
Custom
s
=
bcabc
b
c
a
b
c
0
1
2
3
4
b
c
a
b
c
0
1
2
3
4
b
c
a
b
c
0
1
2
3
4
b
c
a
b
c
0
1
2
3
4
b
c
a
b
c
0
1
2
3
4
candidate from the chosen positions: "bca"
b
c
a
smaller than "bca", keep it
best
"bca"
b
c
a
b
c
0
1
2
3
4
candidate from the chosen positions: "bac"
b
a
c
not smaller than "bca", discard
best
"bca"
b
c
a
b
c
0
1
2
3
4
best
"bac"
b
c
a
b
c
0
1
2
3
4
candidate from the chosen positions: "cab"
c
a
b
not smaller than "bac", discard
best
"bac"
b
c
a
b
c
0
1
2
3
4
best
"bac"
b
c
a
b
c
0
1
2
3
4
candidate from the chosen positions: "abc"
a
b
c
smaller than "abc", keep it
best
"abc"
b
c
a
b
c
0
1
2
3
4
candidate from the chosen positions: "abc"
a
b
c
not smaller than "abc", discard
answer
"abc"
algo
master
.
io
Step:
Brute force: try one position per distinct letter and keep the smallest spelling
0 / 18
Input
Example 1
Example 2
Example 3
Custom
s
=
bcabc
0 / 18
algo
master
.
io
Step:
Brute force: try one position per distinct letter and keep the smallest spelling