Problem
You get a non-empty array of integers nums. Each value appears exactly two times, except one value that appears only one time. Return that value.
Your solution must run in O(n) time and use O(1) extra space, where n is the length of nums. O(1) extra space means that the extra memory does not grow with n.
Example 1
- Input:
- nums = [6,3,6]
- Output:
- 3
Example 2
- Input:
- nums = [8,-2,5,8,5]
- Output:
- -2
- Explanation:
- The values 8 and 5 appear two times. Only -2 appears one time.
Constraints
- 1 <= nums.length <= 3 * 10^4
- -3 * 10^4 <= nums[i] <= 3 * 10^4
- Each value appears two times, except one value that appears one time.
SysRound wrote this statement. A reference solution checks every example.
Related questions
Continue with questions that share topics or the same question type.
- Number of Ways to Wear Different Hats to Each Other
Coding · Array · Bipartite Graph · Bit Manipulation
- Beautiful Arrangement
Coding · Array · Backtracking · Bit Manipulation
- Maximum Bitwise AND After Increment Operations
Coding · Array · Bit Manipulation · Greedy
- Optimal Account Balancing
Coding · Array · Backtracking · Bit Manipulation
Sources · 2 references
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 1 record
Amazon
Leetcode 136. Single Number
Reported Dec 7, 2024 · 1 source report
MID_LEVEL
Source snapshot: Nov 12, 2026
View source
LeetCode company tags · 5 records
Bloomberg
Single Number
Reported date not specified · Source window: 3mo
Source snapshot: Oct 20, 2026
Source frequency score: 66.4. This is not an interview probability.
View sourceBloomberg
Single Number
Reported date not specified · Source window: 6mo
Source snapshot: Oct 20, 2026
Source frequency score: 68.3. This is not an interview probability.
View sourceMeta
Single Number
Reported date not specified · Source window: 30d