Single Number
Easy
Arrays
Array
Bit Manipulation
Given an array where every element appears twice except one, find that single element.
Constraints
1 ≤ nums.length ≤ 3 × 10^4
Examples
Example 1:
Input: 2 2 1
Output: 1
Example 2:
Input: 4 1 2 1 2
Output: 4
Hints
XOR all numbers. a^a=0, a^0=a.
Tests:
Runtime:
Memory:
Test
Input:
Expected:
Got:
Click Run Code to test against sample cases, or Submit to test against all cases.
▲ Console