← 返回 meta 的题目列表Minimum Removal to Make Parentheses Valid
类型:online_judge
meta
Given a string containing only '(' and ')', remove the minimum number of parentheses in any position so that the resulting parentheses string is valid. A valid parentheses string is defined as follows:
Any left parenthesis '(' must have a corresponding right parenthesis ')'.
Left parentheses must go before the corresponding right parenthesis.
Example:
Input: "lee(t(c)o)de)" Output: "lee(t(c)o)de", "lee(t(co)de)", or "lee(t(c)ode)"
Input: "a)b(c)d" Output: "ab(c)d"
Input: "))((" Output: ""
You may return any valid result.
Maximum input size: The length of the string will not exceed 10^5.
Example
Input
lee(t(c)o)de)