Find the missing sequence number with XOR
An exchange feed stamps each message with a sequence number. A clean session should contain every number from to exactly once, but one message was dropped, so the array of received numbers has length and is missing exactly one value from that range.
received = [3, 0, 1] # range is 0..3, so 2 is missing
-> 2
Find the missing sequence number in time and space. Summing and subtracting works but can overflow on huge ranges; the interviewer wants the XOR version.
Show a hint
If you XOR together every index and every received value, what cancels?
Your answer
This one is open-ended. Work it through, then check your reasoning against the full solution.