#C5093. Subarray Detection
Subarray Detection
Subarray Detection
You are given two arrays of integers. Determine whether the second array is a contiguous subarray of the first array.
A subarray of an array A is defined as a segment A[i], A[i+1], \(\ldots\), A[i+m-1] for some index i and length m, where \(0 \leq i \leq n-m\) if \(n\) is the length of A. Note that by definition, an empty array is considered a subarray of any array.
Your task is to print "YES" if the second array appears as a contiguous segment in the first array, and "NO" otherwise.
inputFormat
The input is given from stdin and consists of four lines:
- The first line contains an integer \(n\), the number of elements in the first array.
- The second line contains \(n\) space-separated integers representing the elements of the first array.
- The third line contains an integer \(m\), the number of elements in the second array.
- The fourth line contains \(m\) space-separated integers representing the elements of the second array. If \(m = 0\), this line may be empty.
outputFormat
Output a single line to stdout containing either "YES" if the second array is a subarray of the first array, or "NO" if it is not.
## sample7
1 2 3 4 5 6 7
3
3 4 5
YES