You are given two strings, ransomNote and magazine. Your task is to determine whether the characters in ransomNote can be fully formed using the characters available in magazine.
Each character from magazine can be used only one time.
Return true if constructing ransomNote is possible; otherwise, return false.
Input: ransomNote = "abc" magazine = "cba"
Output: true
Explanation:
All letters required for "abc" exist in "cba".
Input: ransomNote = "hello" magazine = "hleolw"
Output: true
Explanation:
The magazine contains all letters needed: h, e, l, l, o.
Input: ransomNote = "aaab" magazine = "aaba"
Output: true
Explanation:
RansomNote needs 3 × 'a', but magazine has only 2 × 'a'.
Accepted:
Submission: