paint-brush
Implementing Stack Using Queueby@deft
410 reads
410 reads

Implementing Stack Using Queue

by Sergey Golitsyn4mSeptember 15th, 2022
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Sergei Golitsyn proposes a last-in-first-out (LIFO) stack using only two queues. The implemented stack should support all the functions of a normal stack (`push`,`top`),`pop` and `empty` The second variant is how we can solve the problem with a single queue. The last element in the queue will be the first element that was pushed to the top of the stack and the last one in a queue is the last element that has been pushed.
featured image - Implementing Stack Using Queue
Sergey Golitsyn HackerNoon profile picture
Sergey Golitsyn

Sergey Golitsyn

@deft

Senior Software Engineer with 7+ YoE building massively scalable systems both from scratch and diving into a codebase

About @deft
LEARN MORE ABOUT @DEFT'S
EXPERTISE AND PLACE ON THE INTERNET.
L O A D I N G
. . . comments & more!

About Author

Sergey Golitsyn HackerNoon profile picture
Sergey Golitsyn@deft
Senior Software Engineer with 7+ YoE building massively scalable systems both from scratch and diving into a codebase

TOPICS

THIS ARTICLE WAS FEATURED IN...

Permanent on Arweave
Read on Terminal Reader
Read this story in a terminal
 Terminal
Read this story w/o Javascript
Read this story w/o Javascript
 Lite
Javarush
Sumi
Unni
Tefter