Skip to content

Instantly share code, notes, and snippets.

🙂
Love Open Source!

Egor Pishchalnikov tjbulick

🙂
Love Open Source!
Block or report user

Report or block tjbulick

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@tjbulick
tjbulick / queue-using-two-stacks.js
Created Jan 17, 2020
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) {
this.inbox.push(item);
}
You can’t perform that action at this time.