#C3177. Magazine Word Formation
Magazine Word Formation
Magazine Word Formation
Given a magazine string and a target word, determine whether the word can be formed using the characters from the magazine. The matching is case-insensitive — i.e., uppercase and lowercase letters are considered identical.
Formally, for each character c in the word, let \( m(c) \) be the frequency of c in the magazine (after converting both strings to lowercase) and \( w(c) \) be the frequency in the word. The word can be formed if and only if
\[ \forall c,\ m(c) \ge w(c) \]
If the word is empty, output True by definition.
inputFormat
The input consists of two lines. The first line is the magazine string and the second line is the word that you want to form.
outputFormat
Output a single line: True if the word can be formed from the magazine string, or False otherwise.
The quick brown fox jumps over the lazy dog
lazyTrue