Dequeue efficient queue using stack

sir i m not abke to find error in it , pleas ehelp me

in the enqueue operation, you are popping an element to check if it is equal to a certain value, and then when pushing it you are popping another element. This is where it gives Runtime Error. Either use stack.peek() where you are checking the condition and then push in another stack using stack.pop() or use stack.pop() and store it in a variable and then check the condition and push the same number iin the stack.

it is still showing some error , it is showing error in some exceptions , please check it once

This is working piece of code. If you add exception handlers, then take care of letting them out.

i didn’t understood what do you mean by letting them out and the last test case is giving run error

I meant that if you specify that some function throws some Exception, then take care of the fact that the function SHOULD throw that exception either directly or indirectly.

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.