#C4415. Word Construction Check
Word Construction Check
Word Construction Check
You are given two strings: one representing a set of available letters and the other representing a word. Your task is to determine if the word can be constructed using the letters provided. Each letter in the available letters can be used at most once. For example, if you have letters "aabcd" and the word is "bac", the answer is "YES" since all characters of the word can be matched with a subset of the available letters.
Note: Each character is case-sensitive and can only be used as many times as it appears in the given letters.
Mathematically, if we represent the frequency of each letter \( c \) in the available letters as \( f(c) \) and in the word as \( g(c) \), then the word can be constructed if and only if for every character \( c \):
[ g(c) \leq f(c) \quad \forall c ]
inputFormat
The input consists of two lines:
- The first line contains a non-empty string representing the available letters.
- The second line contains a non-empty string representing the word to be constructed. These strings may also be empty, in which case the answer should be determined accordingly (an empty word can always be constructed).
outputFormat
Output a single line containing either "YES" if the word can be constructed using the given letters, or "NO" if it cannot.
## sampleaabcd
bac
YES