#K72552. Subsequence Checker
Subsequence Checker
Subsequence Checker
Given two integer sequences, determine whether the first sequence is a subsequence of the second. A sequence (A = a_1, a_2, \dots, a_n) is a subsequence of (B = b_1, b_2, \dots, b_m) if there exist indices (1 \leq i_1 < i_2 < \cdots < i_n \leq m) such that (a_j = b_{i_j}) for all (1 \leq j \leq n). This means the elements of the first sequence appear in the second sequence in the same order (they do not need to be consecutive).
Read the input from standard input and print the answer to standard output.
inputFormat
The first line contains two integers (n) and (m) representing the lengths of the subsequence and main sequence respectively. The second line contains (n) space-separated integers (the subsequence). The third line contains (m) space-separated integers (the main sequence). Note: If (n = 0), the second line will be empty.
outputFormat
Output a single line: "YES" if the first sequence is a subsequence of the second, otherwise "NO".## sample
3 5
1 2 3
1 2 3 4 5
YES