#code
class Queue { #stack1 = [] #stack2 = [] add(value){ this.#stack1.push(value) return this.#stack1.length } delete(){ while(this.#stack1.length){ this.#stack2.push(this.#stack1.pop()) } const popValue = this.#stack2.pop() while(this.#stack2.length){ this.#stack1.push(this.#stack2.pop()) } return popValue } get length(){ return this.#stack1.length } }
标签:两个,队列,.#,pop,实现,length,push,stack2,stack1 From: https://www.cnblogs.com/zhenjianyu/p/17067509.html