@@ -0,0 +1,1118 @@
+/*%0A *  MostFrequentIntegerInAnArray.java%0A *  Author: Akhash Ramamurthy%0A *  Created on: Aug 13, 2017%0A */%0A%0Apackage com.akh.algorithms.dataStructure.array;%0A%0Aimport java.util.HashMap;%0Aimport java.util.Map;%0Aimport java.util.Map.Entry;%0Aimport java.util.Set;%0A%0A/**%0A *  @fileName: MostFrequentIntegerInAnArray.java%0A *  @author: Akhash Ramamurthy%0A *  Created on: Aug 13, 2017%0A */%0A%0Apublic class MostFrequentIntegerInAnArray %7B%0A%0A%09public static void main(String%5B%5D args) %7B%0A%09%09int%5B%5D items = new int%5B%5D%7B2,1,43,1,6,73,5,4,65,1,3,6,1,1%7D;%0A%09%09System.out.println(%22Most common item = %22+getMostFrequentInt(items));%0A%09%7D%0A%09%0A%09//Time Complexity = O(N)%0A%09//Space Complexity = O(N)%0A%09public static int getMostFrequentInt(int%5B%5D items)%7B%0A%09%09Map%3CInteger, Integer%3E itemsMap = new HashMap%3CInteger, Integer%3E(items.length);%0A%09%09for(int item : items)%7B%0A%09%09%09if(!itemsMap.containsKey(item))%0A%09%09%09%09itemsMap.put(item, 1);%0A%09%09%09else%0A%09%09%09%09itemsMap.put(item, itemsMap.get(item)+1);%0A%09%09%7D%0A%09%09%0A%09%09int maxCount = Integer.MIN_VALUE;%0A%09%09for(Entry%3CInteger, Integer%3E entry : itemsMap.entrySet())%7B%0A%09%09%09if(entry.getValue() %3E maxCount)%0A%09%09%09%09maxCount = entry.getValue();%0A%09%09%7D%0A%09%09return maxCount;%0A%09%7D%0A%7D%0A

Most common integer in an array. Implementation using HashMap. Time O(N), Space O(N)