#K40917. String Derivation Problem
String Derivation Problem
String Derivation Problem
Given two non-empty strings A and B, determine whether string B can be derived from string A by deleting some characters without changing the order of the remaining characters.
Formally, string B can be derived from A if and only if there exist indices \(1 \leq i_1 < i_2 < \dots < i_{|B|} \leq |A|\) such that \(A[i_k] = B[k]\) for all \(1 \leq k \leq |B|\). If this condition is satisfied, output "YES"; otherwise, output "NO".
This is a straightforward simulation problem and can be solved using a two-pointer technique.
inputFormat
The first line of input contains an integer T, denoting the number of test cases. Each of the following T lines contains two strings A and B separated by a space.
outputFormat
For each test case, output a single line containing either "YES" if string B can be derived from string A by deleting some characters (while preserving order), or "NO" otherwise.
## sample3
abpcplea apple
helloworld hello
monkey money
YES
YES
YES
</p>