### Question:
Ransom { public static boolean canRansom(String magazine, String ransom) { if (magazine.length() < ransom.length()) { return false; } Map<String, Integer> magMap = new HashMap<>(); for (String word : magazine.split(" ")) { if (magMap.containsKey(word)) { magMap.put(word, magMap.get(word) + 1); } else { magMap.put(word, 1); } } for (String word : ransom.split(" ")) { if (!magMap.containsKey(word)) { return false; } if (magMap.get(word) == 1) { magMap.remove(word); } else { magMap.put(word, magMap.get(word) - 1); } } return true; }  static boolean canRansom(String magazine, String ransom);  }### Answer:
@Test public void testCanRansom() throws Exception { boolean yayRansom = Ransom.canRansom("dying wool is what you will be doing", "you will be dying"); System.out.println("You " + (yayRansom ? "can" : "can't") + " write a ransom letter"); boolean failRansom = Ransom.canRansom("can you believe Justin Beiber's new shirt?", "give me all your money"); System.out.println("You " + (failRansom ? "can" : "can't") + " write a ransom letter"); Assert.assertTrue(yayRansom); Assert.assertFalse(failRansom); }