题目链接:https://leetcode-cn.com/problems/n-repeated-element-in-size-2n-array/
题目如下:
class Solution {
public int repeatedNTimes(int[] A) {
int n=A.length/2;
HashMap<Integer,Integer> hashmap=new HashMap<Integer,Integer>();
for(int i=0;i<n*2;i++){
int count=hashmap.getOrDefault(A[i],0)+1;
if(count==n) return A[i];
else hashmap.put(A[i],count);
}
return -1;
}
}