#K74297. Subarray Contiguity Check

    ID: 34166 Type: Default 1000ms 256MiB

Subarray Contiguity Check

Subarray Contiguity Check

You are given two arrays of integers. Your task is to determine whether the first array is a contiguous subarray of the second array. Formally, let (A) be the first array with (n) elements and (B) be the second array with (m) elements. You need to check if there exists an index (i) (where (0 \leq i \leq m - n)) such that (B[i], B[i+1], \ldots, B[i+n-1]) exactly equals (A).

Return "Yes" if such an index exists, otherwise return "No".

inputFormat

The input is read from standard input (stdin) and consists of four lines:

1. The first line contains an integer (n): the number of elements in the first array.
2. The second line contains (n) space-separated integers representing the first array.
3. The third line contains an integer (m): the number of elements in the second array.
4. The fourth line contains (m) space-separated integers representing the second array.

outputFormat

Output a single line to standard output (stdout) containing "Yes" if the first array is a contiguous subarray of the second array, and "No" otherwise.## sample

2
2 3
4
1 2 3 4
Yes