I want to find all “entry pairs with maximum value” from a Hashtable, my Hashtable is like this —
Hashtable<Integer, Integer> ht = new Hashtable<Integer, Integer>();
ht.put(1, 4);
ht.put(2, 2);
ht.put(3, 4);
ht.put(4, 2);
ht.put(5, 4);
I want to find these key-value pairs: <1,4>, <3,4>, <5,4>, I understand it could be done by finding the maximum valued entry first, then reiterate through the Hashtable to find other similar entries. But I was wondering if there is any elegant/simpler way to do this.
any idea ?
1 Answer