Note From Magazine Letters
You want to write the note note by cutting letters out of the text magazine. Every letter you cut can be used once. Return true if the magazine has enough of every letter the note needs, and false if not.
Both strings hold only lowercase letters a–z. The letters can come from anywhere in the magazine, in any order.
Examples
note = "meet", magazine = "teeming" → true
note = "noon", magazine = "nominal" → false
note = "", magazine = "abc" → true
note = "cab", magazine = "abacus" → trueIn the second example the note needs two os, and "nominal" has only one. An empty note needs nothing, so any magazine will do.
Constraints
- Each string holds between 0 and 50,000 letters.
- Aim for O(n) in the length of both strings together.
Console
›Run to see what your code prints
Run checks the 4 visible cases here, in your browser. Submit runs all 9 on the judge, 5 of them hidden, and measures how your solution scales.
Expected is the reference solution's answer, from the judge. An input that breaks the statement's other rules may get any answer.