Hash Tables: Ransom Note

  • + 1 comment

    The order comes from the logic of what you want to do. Imagine it as a pipeline. You want to take the entrySet (key, value), stream it (i.e. "play it one by one"), then map eaxh entry to an integer, and finally keep only the negative ones, and get the first one. The Optional xan either be empty or have a value. If it does indeed have a value, the whole pipeline would have ended eagerly due to lazy initialization of streams. It would be equivalent with looping through the entrySet and breaking out of the loop as soon as you find a negative value.