publicclassTwoSum {/* * @param number: An integer * @return: nothing */privateMap<Integer,Integer> map =newHashMap<>();publicvoidadd(int number) {// write your code heremap.put(number,map.getOrDefault(number,0) +1); }/* * @param value: An integer * @return: Find if there exists any pair of numbers which sum is equal to the value. */publicbooleanfind(int value) {// write your code herefor (Map.Entry<Integer,Integer> e :map.entrySet()) {int i =e.getKey();int j = value - i;int count =e.getValue();if ((i == j && count >1) || (i != j &&map.containsKey(j)) ) {returntrue; } }returnfalse; }}