Queues Using Stacks

Run Settings
LanguageJavaScript
Language Version
Run Command
class Queue{ constructor(){ this.front = 0; this.rear = 0; this.length = 0; this.stack = []; this.revstack = []; } enqueue(value) { this.stack[this.rear]= value; this.rear++; } dequeue(){ if(this.front>this.rear) console.log('empty'); let value = this.stack.splice(this.front,1); this.front++; return value; } }
Editor Settings
Theme
Key bindings
Full width
Lines