/** * @return {number} */ FrontMiddleBackQueue.prototype.popFront = function() { if(!this.arr.length) return-1 let a = this.arr[0] this.arr.splice(0,1) return a };
/** * @return {number} */ FrontMiddleBackQueue.prototype.popMiddle = function() { if(!this.arr.length) return-1 let mid = this.arr.length % 2 ==0? this.arr.length/2-1: (this.arr.length-1)/2 let a = this.arr[mid] this.arr.splice(mid,1) return a };
/** * @return {number} */ FrontMiddleBackQueue.prototype.popBack = function() { if(!this.arr.length) return-1 let a = this.arr[this.arr.length-1] this.arr.splice(this.arr.length-1,1) return a };
/** * Your FrontMiddleBackQueue object will be instantiated and called as such: * var obj = new FrontMiddleBackQueue() * obj.pushFront(val) * obj.pushMiddle(val) * obj.pushBack(val) * var param_4 = obj.popFront() * var param_5 = obj.popMiddle() * var param_6 = obj.popBack() */