class Solution {
public:
/**
* 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
*
*
* @param arr intvector
* @param k int
* @return int
*/
int foundOnceNumber(vector<int>& arr, int k) {
int n = arr.size();
map<int, int> mp;
for (int i = 0; i < n; i++) {
if (mp.find(arr[i]) == mp.end()) {
mp[arr[i]] = 1;
} else {
mp[arr[i]] = 2;
}
}
for (int i = 0; i < n; i++) {
if(mp[arr[i]] == 1) {
return arr[i];
}
}
return -1;
// write code here
}
};