Question DSA-BIT-0020
HardTwo numbers appear once and every other number appears twice in an array. How can both be found in O(n) time and O(1) space?
- A.
Use a hash map
- B.
It needs O(n²) time
- C.
XOR everything to get a ^ b, use any set bit of it to split the numbers into two groups, then XOR each group
- D.
Sort the array
Sign up free to see the answer and a step-by-step explanation.