Balanced Parenthesis Please help
Hi @arsh_goyal,
In this, when s[i] is ‘)’ or ‘]’ or ‘}’, u not only need to check whether top most element is ‘(’ or ‘{’ or ‘[’ or stack is not empty, But u also need to check that if s[i]=’)’, whether topmost element is ‘(’, since if for s[i]=’)’, if topmost element is ‘[’ , the string is not balanced . i.e u need to check for every case separately.
Hope this resolves ur doubt.
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.