You are viewing a single comment's thread. Return to all comments →
O(n) solution
public static int minDeletions(int[] a) { int max = 1; Map<Integer, Integer> nums = new HashMap<>(); for (int i : a) if (!nums.containsKey(i)) nums.put(i, 1); else { nums.put(i, nums.get(i) + 1); if (max < nums.get(i)) max = nums.get(i); } return a.length - max; }
Seems like cookies are disabled on this browser, please enable them to open this website
Equalize the Array
You are viewing a single comment's thread. Return to all comments →
O(n) solution