电话面试算法题一道:找出数组中重复次数最多的元素并打印
问题不难,看你能给出更优的方案
- import java.util.HashMap;
- import java.util.Iterator;
- import java.util.Map.Entry;
- import commons.algorithm.sort.QuickSort;
- /**
- * 找出数组中重复次数最多的元素并打印
- *
- */
- public class Problem_3 {
- //先快速排序后循环查找 O( n*log2(n) + n )
- public static void find1(int[] arr){
- QuickSort.sort(arr);
- int max = arr[0];
- int pre=1;
- int now=1;