Question DSA-BIT-0062
HardWhat is the output of this code?
def two_singles(a):
x = 0
for v in a: x ^= v
low = x & -x
p = q = 0
for v in a:
if v & low: p ^= v
else: q ^= v
return sorted([p, q])
print(two_singles([1, 2, 1, 3, 2, 5]))
- A.
[5, 6]
- B.
[3, 5]
- C.
[3, 6]
- D.
[1, 2]
Sign up free to see the answer and a step-by-step explanation.