#10

Single Number

Easy
All Problems

10. Single Number#136

Easy Bit ManipulationXOR

Every element appears twice except one. Find the single element.

Examples

Example 1:
Input: [[2,2,1]]
Output: 1
Example 2:
Input: [[4,1,2,1,2]]
Output: 4
Example 3:
Input: [[1]]
Output: 1

Why learn this

One-liner with XOR. Teaches a powerful bit trick that appears in many problems.

Bit ManipulationXOR
Python 3Loading Python engine...
Click "Run Code" to test your solution