1. 遍历N个数组,得到每个数字在N个数组出现的情况。可以用hash table存储,key为数字,value为自定义类型。
2. 根据mappedCount对key排序,同时剔除掉mappedCount < K的key,用mappingInfo *sortedMapping指针数组存储就好
3. 从mappedCount最小的key开始枚举遍历sortedMapping,同时把结果存储hash table,key为uint32 *mapping转出的字符串,value为匹配的数字个数。这里用hash table存储是避免重复计算,用转出的字符串做key是为了查找方便,如果你愿意自定义查找函数,用uint32 *mapping做key更快
4. 遍历hash table,找到count最大的,而key的含义就能得到是哪几个数组。

空间复杂度O(M)
时间复杂度O(M*lgM) M=count(key)


代码如下:

class Solution {
    public int findKthLargest(int[] nums, int k) {
        Arrays.sort(nums);
        if(nums.length==0) return 0;
        int i=nums.length-1;
        int result=0;
        while(k>0){            
            i--;
            k--;
        }        
        return nums[i+1];
    }
}