please point out my error
Stack-Balanced Paranthesis
Hi @itsexp_2302 I have corrected your code :
These are the errors in your code:
- returning inside the for loop in your check function
- instead of if(s.empty()||s.top()=="(") it should be if(s.empty()) only
- you have to output “YES” and “NO” instead of 1 and 0
- consider the case when there is another character apart from ‘(’ and’)’
In case of any doubt feel free to ask
If you got your answer then mark your doubt as resolved
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.
instead of if(s.empty()||s.top()=="(") it should be if(s.empty()) only
this point is wrong as it should be if(s.empty()||s.top()=="(").
you can test your given code for {[(])} by changing conditions in your statements for } ) and ]