Tap here to switch tabs
Problem
Submissions

Problem: Validate Stack Sequences

Validate Stack Sequences gives push and pop arrays containing the same distinct values. Return whether the pop array could result from valid operations on an initially empty stack.

Statement

Given two integer arrays pushed and popped, each with distinct values, determine if this sequence of operations could result from an initially empty stack undergoing a series of push and pop operations. Return true if valid, or false otherwise.

Constraints:

  • 1≤1 \le pushed.length ≤1000\le 1000

  • 0≤0 \le pushed[i] ≤1000\le 1000

  • All the elements of pushed are unique.

  • popped.length is equal to pushed.length

  • popped is a permutation of pushed.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Validate Stack Sequences

Validate Stack Sequences gives push and pop arrays containing the same distinct values. Return whether the pop array could result from valid operations on an initially empty stack.

Statement

Given two integer arrays pushed and popped, each with distinct values, determine if this sequence of operations could result from an initially empty stack undergoing a series of push and pop operations. Return true if valid, or false otherwise.

Constraints:

  • 1≤1 \le pushed.length ≤1000\le 1000

  • 0≤0 \le pushed[i] ≤1000\le 1000

  • All the elements of pushed are unique.

  • popped.length is equal to pushed.length

  • popped is a permutation of pushed.