Remove Invalid Parentheses
Problem statement
Remove the minimum number of parentheses from text so every remaining parenthesis string is valid. Letters and other non-parenthesis characters cannot be removed.
Return every distinct minimum-removal result in lexicographic order.
Function
removeInvalidParentheses(text: String) → String[]Examples
Example 1
text = "()())()"return = ["(())()","()()()"]Removing one closing parenthesis yields the two distinct valid results.
Constraints
0 <= text.length <= 25.