Balanced parenthesis2


show compilation error.
I Know using switch this can be done.
using this approach it can also done or not?

Just add braces after s.top in line 25 and 33, and then your code works.

thanks. the code passes all test cases.
but it does not count {},[] cases in sample
show output no even though balanced

Yeah because you are never inserting them in the stack.
Please change line 11 to
if(curchar==’(’||curchar==’[’||curchar==’{’)

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.