题目描述
blablabla
样例
blablabla
算法1
(先排序。。。) $O(n^2)$
blablabla
时间复杂度分析:blablabla
C++ 代码
class Solution {
public:
vector<int> findNumsAppearOnce(vector<int>& nums) {
int n = nums.size(), tmp = 0;
vector<int> res;
sort(nums.begin(), nums.end());
tmp = nums[0];
for (int i = 1; i < n; i++){
if(tmp != nums[i]) {
res.push_back(tmp);
tmp = nums[i];
}
else tmp = nums[++i];
}
if (nums[n-1] != nums[n-2]) res.push_back(nums[n-1]);
return res;
}
};