On a Meta surface such as Messenger, you are given a string s containing lowercase English letters plus the characters '(' and ')'. Remove the minimum number of parentheses so the resulting string is valid, and return the resulting string.
A parentheses string is valid if every opening parenthesis has a matching closing parenthesis in the correct order. Letters may appear anywhere and do not affect validity.
ss so that the result is validExample 1
s = "lee(t(c)o)de)""lee(t(c)o)de"')' makes the string valid.Example 2
s = "a)b(c)d""ab(c)d"')' after a is unmatched, so it must be removed.Example 3
s = "))(("""1 <= len(s) <= 10^5s[i] is either a lowercase English letter, '(', or ')'