Learn
Practice
Interview
Resources
Newsletter
F
Toggle theme
0
F
0
Toggle menu
Animations
← Back to All Animations
Minimum Remove to Make Valid Parentheses
Bookmark
Stack (Indices)
Two-Pass Counter
Input
Example 1
Example 2
All Invalid
Nested
Custom
s
=
lee(t(c)o)de)
stack (empty)
l
e
e
(
t
(
c
)
o
)
d
e
)
0
1
2
3
4
5
6
7
8
9
10
11
12
stack (empty)
l
e
e
(
t
(
c
)
o
)
d
e
)
0
1
2
3
4
5
6
7
8
9
10
11
12
stack (empty)
l
e
e
(
t
(
c
)
o
)
d
e
)
0
1
2
3
4
5
6
7
8
9
10
11
12
i
'l'
is a letter, keep it
stack (empty)
l
e
e
(
t
(
c
)
o
)
d
e
)
0
1
2
3
4
5
6
7
8
9
10
11
12
i
3
stack (open indices)
l
e
e
(
t
(
c
)
o
)
d
e
)
0
1
2
3
4
5
6
7
8
9
10
11
12
i
3
5
stack (open indices)
l
e
e
(
t
(
c
)
o
)
d
e
)
0
1
2
3
4
5
6
7
8
9
10
11
12
i
'('
push index
5
onto the stack
3
5
stack (open indices)
l
e
e
(
t
(
c
)
o
)
d
e
)
0
1
2
3
4
5
6
7
8
9
10
11
12
i
3
stack (open indices)
l
e
e
(
t
(
c
)
o
)
d
e
)
0
1
2
3
4
5
6
7
8
9
10
11
12
i
'o'
is a letter, keep it
stack (empty)
l
e
e
(
t
(
c
)
o
)
d
e
)
0
1
2
3
4
5
6
7
8
9
10
11
12
i
'd'
is a letter, keep it
stack (empty)
l
e
e
(
t
(
c
)
o
)
d
e
)
0
1
2
3
4
5
6
7
8
9
10
11
12
i
stack (empty)
l
e
e
(
t
(
c
)
o
)
d
e
)
0
1
2
3
4
5
6
7
8
9
10
11
12
result =
"lee(t(c)o)de"
algo
master
.
io
Step:
Use a stack of indices of unmatched '(' to find what to remove.
0 / 29
Input
Example 1
Example 2
All Invalid
Nested
Custom
s
=
lee(t(c)o)de)
0 / 29
algo
master
.
io
Step:
Use a stack of indices of unmatched '(' to find what to remove.