Given two strings ransomNote and magazine, return true if ransomNote can be constructed by using the letters from magazine and false otherwise. Each letter in magazine can only be used once in ransomNote.
Example 1
Input: ransomNote = aab, magazine = baa
Output: true
Explanation: The note needs two a's and one b, and the magazine "baa" has exactly two a's and one b.
Example 2
Input: ransomNote = a, magazine = b
Output: false
Explanation: The note needs an 'a', but the magazine only has a 'b'.
Example 3
Input: ransomNote = aa, magazine = ab
Output: false
Explanation: The note needs two a's, but the magazine has only one.
Count how many of each letter the magazine provides. Then spend those letters on the ransom note — if any letter runs out, the note can't be built.
Run checks all cases above. Submit evaluates all test cases.