Loading problem…
Let q be the number of operations on an initially empty queue.
class TwoStackQueue { constructor() { this.incoming = [] this.outgoing = [] } enqueue(value) { this.incoming.push(value) } dequeue() { if (this.outgoing.length === 0) { while (this.incoming.length > 0) { this.outgoing.push(this.incoming.pop()) } } return this.outgoing.pop() } }