题解 | #栈的压入、弹出序列#
栈的压入、弹出序列
http://www.nowcoder.com/practice/d77d11405cc7470d82554cb392585106
function IsPopOrder(pushV, popV) { // write code here let i=0,j=0; let helper=[]; while(i<pushV.length){ if(pushV[i] ===popV[j]){ i++; j++; while(helper[helper.length-1]=== popV[j] && helper.length>0 && popV.length>0){ let k = helper.pop(); j++; } }else{ helper.push(pushV[i]) i++; } } return helper.length ===0 } module.exports = { IsPopOrder : IsPopOrder };