#K72342. Subsequence Checker
Subsequence Checker
Subsequence Checker
This problem requires you to determine whether a given string \(S_1\) is a subsequence of another string \(S_2\). A string \(S_1\) is said to be a subsequence of \(S_2\) if all the characters of \(S_1\) appear in \(S_2\) in the same relative order (not necessarily contiguous). For example, if \(S_1 = \texttt{abc}\) and \(S_2 = \texttt{ahbgdc}\), then \(S_1\) is a subsequence of \(S_2\), so the answer is YES. Otherwise, the answer is NO.
Note: An empty \(S_1\) is always considered a subsequence of \(S_2\). However, if \(S_2\) is empty and \(S_1\) is not, then \(S_1\) cannot be a subsequence of \(S_2\).
inputFormat
The input is given via standard input and consists of two lines:
- The first line contains the string \(S_1\).
- The second line contains the string \(S_2\).
Note that \(S_1\) and \(S_2\) may contain any characters. \(S_1\) can be an empty string.
outputFormat
Output a single line to standard output. Print "YES" if \(S_1\) is a subsequence of \(S_2\), otherwise print "NO".
## sampleabc
ahbgdc
YES