public static int repeatedNTimes(int[] A) {
Map<Integer,Integer> map = new HashMap<>();
for (int i = 0; i <A.length; i++) {
if (map.get(A[i])==null){
map.put(A[i],1);
}else{
map.put(A[i],map.get(A[i])+1);
}
for (Integer in:map.keySet() ) {
if (map.get(in)>1){
return in;
}
}
}
return 0;
}