Solution to Stack Push Pop Order from Jobdu

10 Aug

Question (in Chinese):

Question Name: Stack Push Pop Order

Question Description: give two integer arrays. The first one is the order to push the integers into stack. To check whether the second one is an valid order to pop the items from the stack.

Input: the input might contain multiple test cases. Inside each test case, the first line includes one intergers N (1 <= N <= 100000), saying the number of items in the operations. The second line contain N integers, to represent the order to push these elements. The third, also the final, line contains N integers, as the result of popping the items.

Output: “Yes” if the pop order is possible. Otherwise, “No”.

The solution is:

Leave a Reply

Your email address will not be published. Required fields are marked *