1var validateStackSequences = function (pushed, popped) {2let stack = [];3let j = 0;45for (let i = 0; i < pushed.length; i++) {6stack.push(pushed[i]);7while (stack.length != 0 && popped[j] == stack[stack.length - 1]) {8stack.pop();9j++;10}11}12return stack.length < 1;13};