deno.land / x / masx200_leetcode_test@10.6.5 / validate-stack-sequences / index.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
function validateStackSequences(pushed: number[], popped: number[]): boolean { const stack: number[] = []; let i = 0; for (const num of pushed) { stack.push(num); while (stack.length && stack[stack.length - 1] === popped[i]) { stack.pop(); i++; } } return stack.length === 0;}export default validateStackSequences;
masx200_leetcode_test

Version Info

Tagged at
a year ago