13. 找出数组中重复的数字
class Solution {
public:
int duplicateInArray(vector<int>& nums) {
map<int, bool> box;
for (auto v : nums)
if (v < 0 || v >= nums.size())
return -1;
for (auto v : nums)
if (box[v]) return v;
else box[v] = 1;
return -1;
}
};