#K3916. Subsequence Transformation Check

    ID: 26359 Type: Default 1000ms 256MiB

Subsequence Transformation Check

Subsequence Transformation Check

Given two strings S and T, determine if T can be obtained as a subsequence of S. In other words, you can remove some characters from S without changing the order of the remaining characters to obtain T.

Formally, string T is a subsequence of S if there exists a sequence of indices \( i_1, i_2, \dots, i_k \) such that \( 1 \le i_1 < i_2 < \cdots < i_k \le |S| \) and \( S[i_1]S[i_2]\cdots S[i_k] = T \).

Examples:

  • For S = "abacdef" and T = "acdf", the answer is YES.
  • For S = "xyaab" and T = "abc", the answer is NO.

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, or NO otherwise.

## sample
abacdef
acdf
YES