2018-01-04 17:32:02
347. Top K Frequency Elements
Given a non-empty array of integers, return the k most frequent elements.
Given [1,1,1,2,2,3 ] and k = 2, return [1, 2].
思路:
Bucket Sort
1. 将元素及其出现的次数 存入到 Map<T1, T2> mapInstance = new HashMap<>() ;
2. 创建 List<Integer>[ ] bucket = new List[ nums.length + 1 ];