一、题目地址
二、具体代码
let stack1 = [];
let stack2 = [];
function push(node)
{
stack1.push(node);
}
function pop()
{
if(stack2.length) {
return stack2.pop();
}else if(!stack1.length) {
return;
}else {
while(stack1.length) {
stack2.push(stack1.pop());
}
}
return stack2.pop();
}
module.exports = {
push : push,
pop : pop
};