FunctionRacerProblemsRace

Odd One Out

EasyBitsPython, JavaScript, TypeScript, Java, C++

Every number in nums appears an even number of times, except for exactly one number, which appears an odd number of times. Return that number. The list is never empty. There is a one pass solution with no extra memory, because the XOR of two equal numbers is 0.

Example 1

nums [2,3,2]
returns 3

2 appears twice and 3 once, so 3 is the odd one out.

Example 2

nums [7]
returns 7

A single number appears once, which is an odd count.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Bits problems