Skip to content
Advertisement

Tag: hashtable

What is the purpose of placing a HashSet inside of a HashMap?

For example: private HashMap<Integer, HashSet> variableName; I understand that HashMap implements Map and doesn’t allow duplicate keys and HashSet implements Set and doesn’t allow for duplicate values, but what is the purpose of placing a HashSet inside of a HashMap? Do they not achieve similar tasks by themselves (though in different ways and with different performance)? What functionality does doing

Count how many pairs of a number appear in an array

Lets say with the array: I want the output to be: For that I created a Hash table. The code : Not sure what to do next to print out the desired output. Been stuck in this simple part for a long time. Answer The calculation of frequencies seems to be fine, only printing part needs to be addressed. To

Advertisement