Please help with the logic

i am unable to think of a logic, please help

its a simple application is stack… all u have to do is if u encounter ) and check if character present on top of stack is ( then it contains redundant brackets… refer to my code https://ide.codingblocks.com/s/605225

yes, i got it, i have dry ran it myself, but i am unable to understand the logic, why it works?, please help explain

what logic are u unable to understand… try to dry run my code… u will get it…

i hope ur doubt is cleared now

What i s the logic behind this approach, I have done the dry run twice and can see that the ans is correct but why is this approach working, I can see 2+2 =4 but i want to understand how i.e. 2+1 = 3 and 3+1 = 4 and that how 2 + 2 =4, can u tell me the logic?

what are u saying?? what 2+2 =4, 2+1 = 3 and 3+1 = 4, 2 + 2 =4 are u taking about… this is just a simple ques with implementation of stack…

u still have any doubt?? or shall i mark this 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.