#C7325. Construct Target Word from Source Phrase
Construct Target Word from Source Phrase
Construct Target Word from Source Phrase
Given a source phrase and a target word (or phrase), determine whether the target can be constructed by using the letters from the source. In this problem, all space characters are ignored and character matching is case-insensitive.
Formally, let \(S\) be the source phrase and \(T\) be the target. After removing all spaces and converting both \(S\) and \(T\) to lowercase, check whether for every character \(c\) in \(T\), the frequency of \(c\) in \(S\) is at least as high as its frequency in \(T\). If this condition is satisfied, output True
; otherwise, output False
.
This problem tests your ability to manipulate strings and use frequency counting techniques, handling edge cases such as empty strings and extra spaces.
inputFormat
The input consists of two lines:
- The first line contains the source phrase.
- The second line contains the target word or phrase.
outputFormat
Output a single line: True
if the target can be constructed from the source; otherwise, False
.
a quick brown fox
quick
True
</p>