1. Use two stacks to implement a queue and complete the Push and Pop operations of the queue. Elements in the queue are of type int.
Let inStack = []; let outStack = []; function push(node) { inStack.push(node) } function pop() { if(outStack.length == 0){ while(inStack.length ! = 0){ outStack.push(inStack.pop()); }
}
return outStack.pop();
Copy the code
} module.exports = { push : push, pop : pop };