public static boolean anonymous_letter(String L, String M) {
    HashMap<Character, Integer> hash = new HashMap<Character, Integer>();
    // Insert all chars in L into a hash table.
    for (char c : L.toCharArray()) {
      if (!hash.containsKey(c))
        hash.put(c, 1);
      else
        hash.put(c, hash.get(c) + 1);
    }

    // Check chars in M that could cover chars in a hash table.
    for (char c : M.toCharArray()) {
      if (hash.containsKey(c)) {
        hash.put(c, hash.get(c) - 1);
        if (hash.get(c) == 0) {
          hash.remove(c);
          if (hash.isEmpty()) {
            return true;
          }
        }
      }
    }
    // No entry in hash means L can be covered by M.
    return hash.isEmpty();
  }