Skip to content

Commit

Permalink
added java solution
Browse files Browse the repository at this point in the history
  • Loading branch information
harshsri28-zz authored Feb 25, 2021
1 parent d49a4fc commit 583d57e
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/0260-Single-Number-III/single_numberIII.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class Solution {
public int[] singleNumber(int[] nums) {
int tmp = nums[0];
for(int i=1; i < nums.length; i++)
tmp ^= nums[i];
tmp = tmp & ~(tmp-1);
int[] res = new int[2];
for(int n : nums)
if( (n & tmp) == 0)
res[0] ^= n;
else
res[1] ^= n;
return res;
}
}

0 comments on commit 583d57e

Please sign in to comment.