A parentheses string is considered valid if it satisfies any of the following conditions:
It is the empty string.
It can be written as
It can be written as
You are given a parentheses string s and a binary string locked, both of length n. A character locked[i] indicates whether s[i] can be modified:
If locked[i] is '1', you cannot alter s[i].
If locked[i] is '0', you can change s[i] to either '(' or ')'.
Return true if it is possible to make s a valid parentheses string, or false otherwise.
Constraints:
n s.length locked.length
n
s[i] is either '(' or ')'.
locked[i] is either '0' or '1'.
A parentheses string is considered valid if it satisfies any of the following conditions:
It is the empty string.
It can be written as
It can be written as
You are given a parentheses string s and a binary string locked, both of length n. A character locked[i] indicates whether s[i] can be modified:
If locked[i] is '1', you cannot alter s[i].
If locked[i] is '0', you can change s[i] to either '(' or ')'.
Return true if it is possible to make s a valid parentheses string, or false otherwise.
Constraints:
n s.length locked.length
n
s[i] is either '(' or ')'.
locked[i] is either '0' or '1'.