Algorithms Playbook
← All problems
EasyBit manipulation →Similar to: Single Number

The odd one out

Problem

Every element of an integer array appears exactly twice, except for one that appears once. Return that element using linear time and constant extra space.

Examples

Input: [4, 1, 2, 1, 2]

Output: 4

Input: [7]

Output: 7

Hints

    Try it first. Every hint reveals a bit more.

    Solution