#K85852. Anagrammatic Subsequence
Anagrammatic Subsequence
Anagrammatic Subsequence
You are given two strings \(A\) and \(B\). Your task is to determine whether \(B\) is an anagrammatic subsequence of \(A\). Formally, we define \(B\) as an anagrammatic subsequence of \(A\) if for every character \(c\) the number of occurrences of \(c\) in \(B\) is less than or equal to the number of occurrences of \(c\) in \(A\); i.e., \[ \text{count}_{B}(c) \leq \text{count}_{A}(c) \quad \text{for all characters } c \] Note that the characters in \(B\) do not need to appear in the same order as in \(A\).
Example:
Input: abcdef fed</p>Output: yes
inputFormat
The input is given via stdin and has the following format:
- An integer \(T\) representing the number of test cases.
- For each test case, there are two lines:
- The first line contains the string \(A\).
- The second line contains the string \(B\).
outputFormat
For each test case, print a single line to stdout containing either yes
if \(B\) is an anagrammatic subsequence of \(A\), or no
otherwise.
5
abcdef
fed
algorithm
logarithm
test
ttew
abcdef
a
yes
yes
no
yes
no
</p>