#C1314. Permutation of Substring

    ID: 42645 Type: Default 1000ms 256MiB

Permutation of Substring

Permutation of Substring

You are given two strings, s and t. Your task is to determine whether there exists a substring in s that is a permutation of t. More formally, check if there exists an index \(i\) (with \(1 \le i \le |s| - |t| + 1\)) such that the substring \(s[i \ldots i+|t|-1]\) contains exactly the same characters (with the same multiplicity) as \(t\).

If such a substring is found, output YES. Otherwise, output NO.

inputFormat

The input consists of four lines:

  1. An integer \(n\) denoting the length of string s.
  2. A string s.
  3. An integer \(m\) denoting the length of string t.
  4. A string t.

Note that the lengths provided are consistent with the strings.

outputFormat

Output a single line containing either YES or NO based on whether there exists a substring of s that is a permutation of t.

## sample
10
cbabcacab
3
abc
YES