Example hashmap value
3 - 2
20 - 2
4 - 2
5 - 3
How to get key value 5
because it has unique/distinct value of 3
different from other with value of 2
Im trying to looping and comparing previous value still working on this. Is there a way to get this without loop because I have loop already and I hope no loop solution to make code run faster.
UPDATE I tried doing below just removing directly and not adding in hashmap but still i get wrong result
int i = a.length - 1; while (a.length > 1) { System.out.println(Arrays.toString(a)); System.out.println(a[i]); System.out.println(ArrayUtils.contains(a, a[i])); if (ArrayUtils.contains(a, a[i])) { // Do some stuff. a = ArrayUtils.removeElement(a, a[i]); } i--; }