8000 logn solution · shivamkumar177/LeetcodeMay@514be5c · GitHub
[go: up one dir, main page]

Skip to content

Commit 514be5c

Browse files
logn solution
1 parent 618ebcb commit 514be5c

File tree

1 file changed

+12
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)
0