I want to find the keys associated with the maximum value in a HashMap<Integer,Integer>
.
I have seen the question Finding Key associated with max Value in a Java Map, but there are certain restrictions while using HashMap
.
Any help would be appreciated.
Best Answer
What you can do here is just sort your HashMap and pick the first or last keys to get max or min values.
Remember -Their may be more then one keys with same value.