Given a non-empty list of integers where every element appears exactly twice except for one element which appears exactly once, find and return that unique element. Your solution should not use extra memory proportional to the input size.
Examples:
Input: nums = [2, 2, 1]
Output: 1
Explanation: 1 appears once, 2 appears twice
Input: nums = [4, 1, 2, 1, 2]
Output: 4
Explanation: 4 appears once, 1 and 2 each appear twice
Input: nums = [1]
Output: 1
Explanation: Only one element, it is the single number
Input: nums = [3, 3, 7, 7, 5]
Output: 5
Explanation: 5 appears once, 3 and 7 each appear twice
Input: nums = [0, 1, 0]
Output: 1
Explanation: 1 appears once, 0 appears twice
Apex Code Editor
Welcome to Lightning Challenge!
How It Works
- • Write your solution in the code editor
- • Connect your Salesforce org to test
- • Submit to check if your solution passes
- • Use hints if you get stuck
Contest Alert
🏆 #CodeEveryDay July 2026
Contest runs July 1 - 31. Complete challenges to climb the leaderboard!
Only the 31 daily challenges shown during this contest count toward points. Earlier dailies don't carry over.