不修改数组找出重复的数字
class Solution {
public:
int duplicateInArray(vector<int>& nums) {
int n, a[10000], h = -1;
n = nums.size();
for(int i = 0; i < n; i++){
a[nums[i]]++;
if(a[nums[i]] == 2){
h = nums[i];
}
}
if(h != -1){
return h;
}
return -1;
}
};