FunctionRacerProblemsRace

Largest XOR of Any Pick

HardBitsPython, JavaScript, TypeScript, Java, C++

Pick any of the items of nums, from any positions, and XOR (^) them all together. Picking nothing gives 0.

Return the largest result a pick can give.

Example 1

nums [9,5,3]
returns 15

9 ^ 5 ^ 3 = 15, and with four bits nothing is larger.

Example 2

nums [6,6]
returns 6

Picking both gives 6 ^ 6 = 0, so pick just one.

Example 3

nums [0]
returns 0

Everything gives 0.

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