#C8832. Is Subsequence?
Is Subsequence?
Is Subsequence?
Given two strings s
and t
, determine whether t
is a subsequence of s
. A string t
is a subsequence of s
if and only if you can obtain t
by deleting some or no characters from s
without changing the order of the remaining characters. In other words, if s = s_1 s_2 \ldots s_n
and t = t_1 t_2 \ldots t_m
, then t
is a subsequence of s
if there exist indices \(1 \leq i_1 < i_2 < \ldots < i_m \leq n\) such that \(s_{i_1} = t_1, s_{i_2} = t_2, \ldots, s_{i_m} = t_m\).
Note: An empty string is considered a subsequence of any string.
inputFormat
The input consists of two lines. The first line contains the string s
, and the second line contains the string t
.
outputFormat
Output a single line containing "YES" if t
is a subsequence of s
, and "NO" otherwise.## sample
abcde
ace
YES