Validate Stack Sequences
medium
1: Given two sequences pushed and popped with distinct values. 2: You have to return true if and only if this could have been the result of a sequence of push and pop operations on an initially empty stack
Constraints
1: pushed is a permutation of popped 2: pushed and popped have distinct values
Format
Input
Input is managed for you
Output
Output is managed for you
Example
Sample Input
1 2 3 4 5
4 5 3 2 1
Sample Output
true
Question Video