JZ3 数组中重复的数字
数组中重复的数字_牛客题霸_牛客网 (nowcoder.com)
//map
import java.util.*;
public class Solution {
public int duplicate (int[] array) {
Map<Integer,Integer> map=new HashMap<>();
for(int i=0;i<array.length;i++){
if(map.containsKey(array[i])==false){
map.put(array[i],1);
}else{
return array[i];
}
}
return -1;
}
}