Staged Release Pipeline

A release pipeline pushes builds into a staging buffer in the order pushed and releases them to production in the order popped. The buffer behaves as a stack: only the most recently staged build can be released next. Builds are staged one at a time, but a release may happen at any point after the needed build is on top of the buffer.

Determine whether popped could be a valid release order for the given pushed order. The two sequences must use the same builds, each build is identified by its integer id, and the staging buffer starts empty. Return true if the release sequence is achievable, otherwise false.

Every push is consumed exactly once and every pop removes the current top. An interleaving of pushes and pops realizes popped exactly when a stack simulation succeeds.

Examples
Input: [[1,2,3,4,5],[4,5,3,2,1]]
Output: true
Hints

Staged Release Pipeline

A release pipeline pushes builds into a staging buffer in the order `pushed` and releases them to production in the order `popped`. The buffer behaves as a stack: only the most recently staged build can be released next. Builds are staged one at a time, but a release may happen at any point after the needed build is on top of the buffer.