Subsequence check
Problem
Check if a sequence is a subsequence of the given array.
Input
The first line of the input contains the number N – the length of the given sequence (1 ≤ N ≤ 10000). The second line contains the members of the original sequence (separated by a space) – integers not exceeding 10000 modulo.
The third line contains the number M – subsequence length (1 ≤ M ≤ 10000). The fourth line specifies the members of the subsequence (separated by a space) – integers not exceeding 10000 modulo.
Imprint
Output "YES" if the sequence given in the 4th line is a subsequence of the given array and "NO" if it is not.
Input |
Output |
10
1 2 3 4 5 6 7 8 9 10
10
1 2 3 5 4 6 7 8 9 10
| NO |
10
1 2 3 4 5 6 7 8 9 10
9
1 2 3 5 6 7 8 9 10
| YES |
Explanation.
Don't confuse "subsequence" with with "substring".