题解 | #数组中重复的数字#
数组中重复的数字
https://www.nowcoder.com/practice/6fe361ede7e54db1b84adc81d09d8524
class Solution {
public:
int duplicate(vector<int>& numbers) {
int a[10000]={0};
for(auto &e:numbers)
{
a[e]++;
}
for(int i=0;i<10000;++i)
{
if(a[i]>=2)
return i;
}
return -1;
}
};