#C1826. Subsequence Check
Subsequence Check
Subsequence Check
Given two strings s and t with lengths n and m respectively, determine whether t is a subsequence of s. A string t is a subsequence of s if there exists a sequence of indices \(1 \le i_1 < i_2 < \cdots < i_m \le n\) such that \( s[i_k] = t[k] \) for all \(k = 1, 2, \ldots, m\).
Your task is to read from the standard input the parameters and output "YES" if t is a subsequence of s, or "NO" otherwise.
inputFormat
The input is read from standard input and consists of four lines:
- The first line contains an integer
n
denoting the length of strings
. - The second line contains the string
s
. - The third line contains an integer
m
denoting the length of stringt
. - The fourth line contains the string
t
.
outputFormat
Print a single line to standard output containing "YES" if t
is a subsequence of s
, or "NO" otherwise.
7
abacaba
4
baca
YES
</p>