haoel/leetcode

How do you handle target - num = num case

Werror opened this issue · 1 comments

If we have [1 10 50 90] and we trying to find 100.
Wouldn't map find return the 50 which have just inserted already?

Thanks,
Werror

In a map, each element is associated with a key-value pair, and it allows efficient retrieval of values based on their keys.

If you have a std::map with keys [1, 10, 50, 90], and you are trying to find the element associated with the key 100, the map::find function would return an iterator pointing to the end of the map (i.e., map.end()). It wouldn't modify the map or insert any new element.