Skip to content

Instantly share code, notes, and snippets.


Egor Pishchalnikov tjbulick

View GitHub Profile
tjbulick / queue-using-two-stacks.js
Created January 17, 2020 08:32
Implementation of Queue data structure using two stacks in JavaScript. Actually, it uses two arrays here(because there is no stack in JavaScript), but you should have a look at your language docs: perhaps it provides embedded stack data structure. (For example: Java provides class "Stack", C# similarly, etc.)
View queue-using-two-stacks.js
class Queue {
constructor() {
this.inbox = [];
this.outbox = [];
enqueue(item) {