You are viewing a single comment's thread. Return to all comments →
why use complex data structures ? just continue with the given snap of code using arrays...
Arrays.sort(magazine); Arrays.sort(ransom);
List magazine_words = new ArrayList(Arrays.asList(magazine));
for (String ransom_w : ransom) { if (!magazine_words.remove(ransom_w)) { System.out.println("No"); return ; } } System.out.println("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 →
why use complex data structures ? just continue with the given snap of code using arrays...
Arrays.sort(magazine); Arrays.sort(ransom);
List magazine_words = new ArrayList(Arrays.asList(magazine));
for (String ransom_w : ransom) { if (!magazine_words.remove(ransom_w)) { System.out.println("No"); return ; } } System.out.println("Yes");