+ 2

Just a question

How can we implement stack using two queue ? queue follows FIFO pattern . Even if we operate it using dequeue from front and insert it again in queue how will it make stack ? Stack produces LIFO and the last element of queue should be at the top of stack. Anyone explain pls here

24th Sep 2022, 7:49 AM
Davinder Kumar
Davinder Kumar - avatar
4 Respuestas
+ 3
I have implemented it thanks for replying:)
24th Sep 2022, 12:02 PM
Davinder Kumar
Davinder Kumar - avatar
+ 3
Ipang so as per your demand, i have made a code playground 😌 https://code.sololearn.com/c4jKOh5wfB75/?ref=app
24th Sep 2022, 3:55 PM
Davinder Kumar
Davinder Kumar - avatar
+ 2
Davinder Kumar , not quite sure what you wanted to achieve. to give you helpful hints we need to get some more details. > can you prepare input data and the expected output? > please also mention the programming language you are going to use.
24th Sep 2022, 11:30 AM
Lothar
Lothar - avatar
+ 2
Davinder Kumar You can add that code in post Description for those people who may need it in the future 👍 It may be better to have "Implementation of stack using queue" in post title for easier search ...
24th Sep 2022, 2:05 PM
Ipang