题解 | #栈的压入、弹出序列#
栈的压入、弹出序列
https://www.nowcoder.com/practice/d77d11405cc7470d82554cb392585106
function IsPopOrder(pushV, popV)
{
// write code here
let helparr = [];
let ind = 0;
for(let i of pushV) {
helparr.push(i);
while(helparr.length > 0) {
if(helparr[helparr.length - 1] == popV[ind]){
helparr.pop();
ind = ind + 1;
}else{
break;
}
}
}
return helparr.length == 0;
}
module.exports = {
IsPopOrder : IsPopOrder
};
算法题合集 文章被收录于专栏
自己做算法的解题代码

