public boolean IsPopOrder (int[] pushV, int[] popV) { Stack<integer> s1 = new Stack<>(); // write code here int popVIndex = 0; for (int i = 0; i < pushV.length; i++) { s1.push(pushV[i]); while (s1.size() > 0 && s1.peek() == popV[popVIndex]) { s1.pop(); popVIndex++; if (popVIndex == popV.length) return true; } } return false; }</integer>
点赞

相关推荐

水墨不写bug:疑似没有上过大学
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务