class Solution {//根堆排序,相同元素一定在一起
public:
int duplicateInArray(vector< int >& nums) {
priority_queue< int > big_heap;
for(int i=1;i<nums.size();i++)
{
big_heap.push(nums[i-1]);
}
while(!big_heap.empty())
{
int temp= big_heap.top();
big_heap.pop();
if(temp==big_heap.top())
{
return big_heap.top();
}
else{big_heap.pop();}
}
return -1;
}
};