/** * Pushes element x to the back of the queue. * @param {number}x * @return {void} */ MyQueue.prototype.push = function(x) { this.queue.push(x) };
/** * Removes the element from in front of queue and returns that element. * @return {number} */ MyQueue.prototype.pop = function() { while(this.queue.length !== 0){ this.queue2.push(this.queue.pop()) }
/** * Returns the element at the front of the queue. * @return {number} */ MyQueue.prototype.peek = function() { while(this.queue.length !== 0){ this.queue2.push(this.queue.pop()) }
/** * Returns true if the queue is empty, false otherwise. * @return {boolean} */ MyQueue.prototype.empty = function() { returnthis.queue == 0 };
/** * Your MyQueue object will be instantiated and called as such: * var obj = new MyQueue() * obj.push(x) * var param_2 = obj.pop() * var param_3 = obj.peek() * var param_4 = obj.empty() */
[name=@joe94113] [time=Tue, Feb 7, 2023 10:00 PM] [color=#907bf7]