a parenthesis stre nonempty string consist it valid follow condition trueIt it write AB a concatenate B A b valid parenthesis stringsIt write a a valid parenthesis stringYou give parenthesis stre s string lock length n locked binary string consist 0s 1s for index lockedIf lockedi 1 change siBut lockedi 0 change si return true s valid parenthesis stre otherwise return false example 1input s lock 010100output trueexplanation locked1 1 locked3 1 change s1 s3we change s0 s4 leave s2 s5 unchanged s validExample 2input s lock 0000output trueexplanation we need change s validExample 3input s lock 0output falseexplanation lock permit change s0 change s0 s valid Constraintsn slength lockedlength1 n 105si lockedi 0 1