You are viewing a single comment's thread. Return to all comments →
Awesome! Look at my boring old verbose Java solution in comparison :D:
Hashtable<String, Integer> magazine = new Hashtable<String, Integer>(); for(String s : magazineWords){ if(magazine.containsKey(s)){ magazine.put(s, magazine.get(s) + 1); }else{ magazine.put(s, 1); } } for(String s : ransom){ if(!magazine.containsKey(s)){ return "No"; } int counter = magazine.get(s) - 1; if(counter == 0){ magazine.remove(s); }else{ magazine.put(s, counter); } } return "Yes";
Seems like cookies are disabled on this browser, please enable them to open this website
Hash Tables: Ransom Note
You are viewing a single comment's thread. Return to all comments →
Awesome! Look at my boring old verbose Java solution in comparison :D: