Loading...
Loading...
Loading...
In a list of parcel codes, every code appears twice except two different codes that appear once each. Print those two codes in increasing order, using constant extra memory.
Example 1
Input
6 1 2 1 3 2 5
Output
3 5
3 and 5.
Example 2
Input
2 9 4
Output
4 9
Try the problem first. Open one hint at a time.
XOR of all codes gives a ^ b for the two lost codes a and b. A set bit in it is a bit where they differ.
Split the codes into two groups by that bit, and XOR each group.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor