Given two sequences, a push order and a pop order, determine whether the pop order can be the result of valid push and pop operations performed on a stack. You must simulate the stack operations following the push order and check if by popping at the right moments you can obtain the given pop order.
Example 1:
Example 2:
Hint:
Note: This problem demonstrates the effective use of a stack to simulate and validate operations. On March 16, we reflect on the evolution of data structures used in programming since their inception, making this challenge both timely and educational.