Redundant Parantheses doubt


I don’t understand where to put my “Not Duplicate” condition.

@akankshaanand99 I think your logic is wrong, please explain your approach.

In this question, for every opening bracket you have to push it into the stack and for every closing blocks we need to pop the opening bracket and also check if the closing brackets popped are adjacents and at the time same time the popped opening brackets are also adjacent, so if yes then Duplicate.
Feel free to ask if you face any difficulty in implmentation