Single Number

Easy Solved

Description

Given a non-empty array of integers nums, every element appears twice except for one. Find that single one.

You must implement a solution with linear runtime complexity and use only constant extra space.

Input format:

Runner expects a single line stdin containing a JSON array.

Examples

Input: [2,2,1]

Output: 1

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

Output: 4

Note:

Print only the single number so it can be compared with expected output.

No submissions yet.

Discuss XOR-based solution, why it works, and why extra space is not needed.

Test Cases