Brackets all over

sample input

4 2
((

sample output

1
how answer for above test case is 1

(()) this is a string of length 4, and satisfy both the properties

  1. number of opening brackets at every index greater than closing brackets(except ofcourse the last index)
  2. number of opening brackets is 2 and closing brackets is 2, so they are equal
    a=" "(empty string), b = “((”, c = “))”
    a+b+c = “” + “((” + “))” = " (()) "

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

1 Like