2025 Coding Team Tryouts P2 - Subsequencing Strings
String \(T\) is a subsequence of string \(S\) if you can get \(T\) from \(S\) by deleting any number characters from \(S\) (possibly zero).
For example, \(abc\) is a subsequence of \(xaxbxxc\) since we can delete characters \(1\), \(3\), \(5\), and \(6\).
Given \(T\) (\(1 \le |T| \le 10^5\)) and \(S\) (\(1 \le |S| \le 10^5\)), is \(T\) a subsequence of \(S\)?
Input Specification
The first line contains the string \(T\). The second line contains the string \(S\). Both strings only contain lowercase letters.
Output Specification
Output YES or NO: is \(T\) a subsequence of \(S\)?
Sample Input 1
abc
bcxaxbxcx
Sample Output 1
YES
We can delete characters so that only characters \(4\), \(6\), and \(8\) remain.
Sample Input 2
abc
bacb
Sample Output 2
NO
Comments