Python Odd Occurrences In Array
def odd_occurrences_in_array(a: list[int]) -> int | None:
count: dict[int, int] = {}
for value in a:
if value not in count:
count[value] = 1
else:
del count[value]
return next(iter(count), None)
This uses XOR to cancel out pairs, leaving only the value that appears an odd number of times.