from typing import List
class Solution:
def singleNumbers(self, nums: List[int]) -> List[int]:
from functools import reduce
res = reduce(lambda x, y: x ^ y, nums)
div = 1
while div & res == 0: # 111 & 101 == 101, 000 | 101 == 101, 000 ^ 101 == 101
div <<= 1
a, b = 0, 0
for x in nums:
if x & div:
a ^= x
else:
b ^= x
return [a, b]
if __name__ == '__main__':
solution = Solution()
nums = [4, 1, 4, 6]
res = solution.singleNumbers(nums)
print(res)