My code not showing correct answer

can you please check

@aryaman.kumar26 wrong logic applied

@aryaman.kumar26
Question is pretty simple just keep the track of corresponding open and closed brackets.

Algo

  1. Each time you encounter an open bracket simply push it into stack.
  2. If you got any closed bracket.
    2.1 If the stack is empty return false.
    2.2 Check if the closed bracket matches the peek element of stack.
    2.3.1 If yes pop the element and continue.   
    2.3.2  else return false.
  1. At the end return true if stack is empty.

@aryaman.kumar26 try using this if any problem ask me i will share the code for ref

i know the algo but please tell the mistake in my method using deque

@aryaman.kumar26 no if opening bracket you just push and if closing you just pop thats wrong see the algo
code for ref

sir https://ide.codingblocks.com/s/303280 sir case 3 and 4 have failed can you please check the mistake

@aryaman.kumar26 i told you before your algo is wrong
here check for this type of input
[(]) your code gives yes ans no

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.