Advertisement
kosievdmerwe

Untitled

Nov 5th, 2021
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.30 KB | None | 0 0
  1. class Solution:
  2.     def singleNumber(self, nums: List[int]) -> List[int]:
  3.         nums_xor = reduce(xor, nums)
  4.         single_set_bit = (-nums_xor) & nums_xor
  5.        
  6.         num1 = reduce(xor, (n for n in nums if (n & single_set_bit)))
  7.         num2 = nums_xor ^ num1
  8.         return [num1, num2]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement