I have implimented the problem and my code is in the link , please have a look.
I am not able to impliment a Queue using two stack objects
Hey @aanandraj460
I updated your code and mentioned in comments :https://ide.codingblocks.com/s/329652
Some explanation:
You don’t have to swap stacks ,instead u have to empty the second stack again into 1st stack
Say we have (1,2,3) () as stacks where Right end is top
so if we pop we will be doing this (1,2)(3) -> (1)(3,2) ->()(3,2) ->(2)(3)->(2,3)()
But right now when you are swapping you are doing this
(1,2)(3) -> (1)(3,2) ->()(3,2) ->(3,2)()
u see at end in swapping order of elements is reversed.
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.