class Solution { public: int duplicate(vector<int>& numbers) { if(numbers.size()==0) { return -1; } sort(numbers.begin(),numbers.end()); if(numbers[0]<0) { return -1; } for(int i=1;i<numbers.size();i++) { if(numbers[i]==numbers[i-1]) { return numbers[i]; } } return -1; } };