i dont know why is it showing segmentation fault
Balanced Brackets Error
For the input string )(
it is showing error for the input string )(
Replace line 13 with if (s.empty()||s.top()!=’(’) {
empty condition must be checked first in order. Once the first part is true, second part is not checked (in case of OR condition). You code was giving error because the stack was empty and you were performing s.top() operation.
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.