Removing Parentheses
Given a string of parentheses s
, return the minimum number of parentheses to be removed to make the string balanced.
Constraints
n ≤ 100,000
wheren
is the length ofs
https://binarysearch.com/problems/Removing-Parentheses
Examples
Example 1
Input
- s =
)(
Output
- answer =
2
Explanation
We must remove all the parentheses.
Example 2
Input
- s =
()())()
Output
- answer =
1
Explanation
We can remove the ")"
at index 4 to make it balanced.
Leave a comment