sample test case is passing but not others
Regarding the code
@gargshivam2001 when you have made t =1 then at the last for that why you are checking if t==1 then it should be not duplicate.
your logic i right but you have done mistakes.
see this code: https://ide.codingblocks.com/s/420382
if you still have any doubt you can ask here:
Happy Learning!!
sir, I think i have understood the question wrong. can you please explain it once with an example as a testcase ??? It will be of great help
@gargshivam2001 check this:
see if you do the dry run for that test case:
then it will be done like this if character is not equal to ‘)’ then we will directly push it into the stack but if the character is ‘(’ then we will check if the character at the top is ‘(’ then only it will come under redundant but we will pop the elements until the top of the stack is not equal to ‘(’:
so in this way we will dry run for that test case: ((a+(b))+(c+d))
until first ‘)’ stack will be ((a+(b
then the first ‘)’ this will encounter and the stack will become:
((a+
and then another ‘)’ this will come then the stack will become :
(.
now we will push in the stack until character is not equal to ‘)’
then the stack will become:
(+(c+d .
after another closing stack will become :
(+and then the last closing the the stack will be eompty so it is not reduntant you can seee.
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.