Hash Tables: Ransom Note

  • + 1 comment

    Could you explain:

    Optional<Integer> res = ransom.entrySet().stream()
    .map(e -> magazine.getOrDefault(e.getKey(), 0) - e.getValue())
    .filter(e -> e < 0)
    .findFirst();
    

    How did you know how the order of the .entrySet, .stream, .map, etc...?

    I understand what the Optional class does, I am just not experienced with this syntax.