Need for other condition

in if(stack is empty or stack top !=’(’
why do we need second condition stack top !=’(.’ I can still run the code and get correct output without one.

hi @radhika1995 for example, the given string is “((” in this case, the stack is not empty but without the second conditon, it will return true, which is incorrect.

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.