This is very interesting, using approach utilizing Map.Entry is good, such as https://leetcode.com/discuss/19515/my-solutions-java-and-python-time-for-add-time-for-find-space. but still performed much worse than using a list like this one.

I think it is due to HashSet<Key> iterator traversing overhead, comparing to good-old positional traversing.

--- my code using a Map.Entry<>, only beating 50%

```
public class TwoSumIII_170 {
// inspired by: https://leetcode.com/discuss/19515/my-solutions-java-and-python-time-for-add-time-for-find-space
// to use Entry<Key,Val> to optimize, but still no where near the performance
// using a List<Key> that contains all distinct values from:
// https://leetcode.com/discuss/76823/beats-100%25-java-code
// I suspect that this is due to the performance drag by the Set's iterator
Map<Integer, Boolean> num2dupMap = new HashMap<Integer, Boolean>();
// Add the number to an internal data structure.
public void add(int number) {
// add number to a map, if already exist, set it to true
num2dupMap.put(number, num2dupMap.containsKey(number));
}
// Find if there exists any pair of numbers which sum is equal to the value.
public boolean find(int value) {
// for each of the number in the map, get the (value - number)
// try to find (value - number) in the map
// if it exits in the map,
for(Entry<Integer, Boolean> entry: num2dupMap.entrySet()){
int num1 = entry.getKey();
int num2 = value - num1;
if (num1 == num2 && entry.getValue()){
// 1. could be number2 = (value - number1) hence to make sure it not only
// just found the original number, but a 2nd number of the same value,
// we need to && map.get(number2) == true
// then return true
return true;
} else if (num1 != num2 && num2dupMap.containsKey(num2)){
// 2. could be number2 != (value - number1), and if we `enter code here`found it, we
// found a winner
return true;
}
}
return false;
}
}
```