Skip to content

Commit 9f23722

Browse files
author
cpppy
authored
Create 136_Single_Number.cc
1 parent e1dfecc commit 9f23722

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

136_Single_Number.cc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Solution {
2+
public:
3+
int singleNumber(vector<int>& nums) {
4+
if(nums.empty()) return NULL;
5+
sort(nums.begin(),nums.end());
6+
for(int i=0;i<nums.size()-1;++++i){
7+
if(nums[i]!=nums[i+1]){
8+
return nums[i];
9+
}
10+
}
11+
return nums[nums.size()-1];
12+
}
13+
};

0 commit comments

Comments
 (0)