offer31专题

剑指offer31.栈的压入、弹出序列。简单易懂0ms

class Solution {public boolean validateStackSequences(int[] pushed, int[] popped) {Deque<Integer> stack = new ArrayDeque();int j = 0;// j当作popped的指针,判断当前是否是弹出的数值for(int push : pushed){stack.push(push)