#C11297. Subsequence Query
Subsequence Query
Subsequence Query
You are given two strings s
and t
. Your task is to determine whether t
is a subsequence of s
. A subsequence is a sequence that can be derived from s
by deleting some or no characters without changing the order of the remaining characters.
For example, consider s = "coding"
and t = "cdg"
. Here, t
is a subsequence because by deleting the characters o
and i
from s
, we obtain cdng
and the first three letters match t
in order. Conversely, if s = "hello"
and t = "world"
, then t
is not a subsequence of s
.
You need to process multiple queries. For each query, print YES
if t
is a subsequence of s
, otherwise print NO
.
inputFormat
The first line of input contains an integer Q, denoting the number of queries. Each of the next Q lines contains two space-separated strings, s
and t
.
outputFormat
For each query, output the result on a new line. Print YES
if t
is a subsequence of s
, and NO
otherwise.
3
coding cdg
hello world
abcde ace
YES
NO
YES
</p>