Duplicate Finder in Array
easySave
ArrayHash Table
Given an array of integers where each integer appears exactly twice except for one integer which appears only once, find and return the integer that appears only once.
Example 1
Input
[ 2, 3, 2 ]
Output
3
Explanation. The number 3 appears only once while others appear twice.
Example 2
Input
[ 4, 1, 2, 1, 2 ]
Output
4
Explanation. 4 appears only once in the array.
Example 3
Input
[ 10, 10, 1 ]
Output
1
Explanation. 1 is the only number that appears just once.
Follow-up: Can you implement a solution with a linear runtime complexity and without using extra memory space?
Constraints:
1. The input array will contain at least one integer.\n2. All integers appear exactly twice except for one, which appears once.
- Views
- 4