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:
pushed.length
pushed[i]
All the elements of pushed are unique.
popped.length is equal to pushed.length
popped is a permutation of pushed.
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:
pushed.length
pushed[i]
All the elements of pushed are unique.
popped.length is equal to pushed.length
popped is a permutation of pushed.