MCPcopy Create free account
hub / github.com/codedecks-in/LeetCode-Solutions / Solution

Class Solution

Python/single-number-iii.py:55–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53'''
54
55class Solution:
56 def singleNumber(self, nums: List[int]) -> List[int]:
57 xor = reduce(lambda x,y: x^y, nums, 0) #complete xor of list will result in xor of these two unique elements
58 xor = xor&(-xor)
59 first = second = 0
60 for num in nums:
61 if xor & num:
62 first ^= num
63 else:
64 second ^= num
65 return [first, second]

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected