#K74787. Rearrangement and Deletion
Rearrangement and Deletion
Rearrangement and Deletion
You are given two strings \(A\) and \(B\). Your task is to determine whether it is possible to form \(B\) from \(A\) by rearranging the characters and deleting zero or more characters.
In other words, check if every character in \(B\) exists in \(A\) with at least the same frequency. Note that you may reorder \(A\) arbitrarily and remove any unwanted characters.
For instance, if \(A = \texttt{abccba}\) and \(B = \texttt{ab}\), the answer is "yes" since you can rearrange \(A\) and remove extra characters to get \(B\). However, if \(A = \texttt{abc}\) and \(B = \texttt{acd}\), then the answer is "no".
inputFormat
The input consists of two lines. The first line contains the string \(A\), and the second line contains the string \(B\). Both strings consist of lowercase English letters.
outputFormat
Output a single line with either "yes" if it is possible to form \(B\) from \(A\) by rearranging and deleting characters, or "no" otherwise.
## sampleabccba
ab
yes