Stack quiz problem


I am not getting whats the bug in this code ,I think its correct.

You also need to check at the end after the loop terminates that if the stack is empty or not.
If the stack is not empty at the end then the expression must be unbalanced.
Example for ((())
At the end the stack will not be empty but according to the above code, it will print “balanced”

but we should also check if top of stack has ‘(’ then only we can pop na otherwise its not balanced but in question thats also not written.

kbut we should also check if top of stack has ‘(’ then only we can pop na otherwise its not balanced but in question thats also not written.

Just dry run the code with that option, you will get it.

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.