https://leetcode.com/problems/ransom-note/?envType=study-plan-v2&envId=top-interview-150
class Solution {
public boolean canConstruct(String ransomNote, String magazine) {
HashMap<Character, Integer> map = new HashMap();
for (char chr : magazine.toCharArray()) map.put(chr, map.getOrDefault(chr, 0) + 1);
for (int i = 0; i < ransomNote.length(); i++) {
char tmp = ransomNote.charAt(i);
if (map.containsKey(tmp) && map.get(tmp) > 0) {
map.put(tmp, map.get(tmp) - 1);
} else return false;
}
return true;
}
}