Learn
Practice
Interview
Resources
Newsletter
F
Toggle theme
0
F
0
Toggle menu
Animations
← Back to All Animations
Minimum Add to Make Parentheses Valid
Bookmark
Input
Example 1
All open
Balanced
Mixed
Custom
s
=
())
s
0
(
1
)
2
)
unmatchedOpen = 0
unmatchedClose = 0
Matched
Unmatched (
Unmatched )
s
0
(
1
)
2
)
unmatchedOpen = 0
unmatchedClose = 0
Matched
Unmatched (
Unmatched )
s
0
(
1
)
2
)
i
unmatchedOpen = 0
unmatchedClose = 0
Matched
Unmatched (
Unmatched )
s
0
(
1
)
2
)
i
unmatchedOpen = 0
unmatchedClose = 0
Matched
Unmatched (
Unmatched )
s
0
(
1
)
2
)
i
unmatchedOpen = 1
unmatchedClose = 0
Matched
Unmatched (
Unmatched )
s
0
(
1
)
2
)
i
unmatchedOpen = 1
unmatchedClose = 0
Matched
Unmatched (
Unmatched )
s
0
(
1
)
2
)
i
unmatchedOpen = 0
unmatchedClose = 0
Matched
Unmatched (
Unmatched )
s
0
(
1
)
2
)
i
unmatchedOpen = 0
unmatchedClose = 0
Matched
Unmatched (
Unmatched )
s
0
(
1
)
2
)
i
unmatchedOpen = 0
unmatchedClose = 1
Matched
Unmatched (
Unmatched )
s
0
(
1
)
2
)
unmatchedOpen = 0
unmatchedClose = 1
Matched
Unmatched (
Unmatched )
algo
master
.
io
Step:
Start: Count minimum additions to make parentheses valid
0 / 8
Input
Example 1
All open
Balanced
Mixed
Custom
s
=
())
0 / 8
algo
master
.
io
Step:
Start: Count minimum additions to make parentheses valid