LearnPy Hub
← Arena
IntermediateRating 1300

Possible Pop Order?

Numbers are pushed onto a stack in the order of the first list. Pops can happen at any time. Can the pops happen in the order of the second list? Print YES or NO.

Input

n; the push order; the pop order.

Output

YES or NO.

Sample 1

Input
5
1 2 3 4 5
4 5 3 2 1
Output
YES

Sample 2

Input
5
1 2 3 4 5
4 3 5 1 2
Output
NO
solution.py
Output appears here
Possible Pop Order? · Python Arena problem · LearnPy Hub