You are viewing a single comment's thread. Return to all comments →
My Java Solution
static boolean checkMagazine(String[] magazine, String[] note) { Hashtable<String, Integer> m = new Hashtable<>(); Hashtable<String, Integer> n = new Hashtable<>(); for(String i: magazine){ m.put(i,m.getOrDefault(i,0)+1); } for(String j: note){ if(m.getOrDefault(j,0)==0) return false; else m.put(j,m.get(j)-1); } return true; }
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 →
My Java Solution