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.

&nbsp;
Example 1:
Input: ransomNote = "a", magazine = "b"
Output: false
Example 2:
Input: ransomNote = "aa", magazine = "ab"
Output: false
Example 3:
Input: ransomNote = "aa", magazine = "aab"
Output: true

&nbsp;
Constraints:


	1 &lt;= ransomNote.length, magazine.length &lt;= 105
	ransomNote and magazine consist of lowercase English letters.


from collections import Counter
class Solution:
    def canConstruct(self, ransomNote: str, magazine: str) -> bool:
         
        ransomNote_count = dict(Counter(ransomNote))
        magazine_count = dict(Counter(magazine))
        
        for key , value in ransomNote_count.items():
            
            if key in magazine_count:
                if value <= magazine_count[key]:
                    continue
            else:
                return False
            
            return False
        
        return True
class Solution {
    public boolean canConstruct(String ransomNote, String magazine) {
        char[] rs = ransomNote.toCharArray();
        char[] ms = magazine.toCharArray();
        
        HashMap<Character, Integer> rm = new HashMap<>();
        HashMap<Character, Integer> mz = new HashMap<>();
        
        for (char c : rs) {
            if (rm.containsKey(c)) {
                rm.put(c, rm.get(c) + 1);
            } else {
                rm.put(c, 1);
            }
        }

        for (char c : ms) {
            if (mz.containsKey(c)) {
                mz.put(c, mz.get(c) + 1);
            } else {
                mz.put(c, 1);
            }
        }

        for (char c : rm.keySet()) {
            if (!mz.containsKey(c) || mz.get(c) < rm.get(c)) {
                return false;
            }
        }
        return true;  
    }
}
class Solution {
public:
    bool canConstruct(string ransomNote, string magazine) {
        int cnt[26] = {0};
        for(char x: magazine)
            cnt[x-'a']++;
        
        for(char x: ransomNote) {
            if(cnt[x-'a'] == 0)
                return false;
            cnt[x-'a']--;
        }
        
        return true;
    }
};
var canConstruct = function(ransomNote, magazine) {
    map = {};
    for(let i of magazine){
        map[i] = (map[i] || 0) + 1;
    }
    for(let i of ransomNote){
        if(!map[i]){
            return false
        }
        map[i]--;
    }
    return true
};
Ransom Note