Single Number
Very easy Bit Manipulation
nums is a list of whole numbers.
Every value in nums appears exactly twice, except one value, which appears only once.
Return the value that appears once.
Example 1
Input: nums = [7,-2,5,7,5]
Output: -2
7 and 5 each appear twice, at positions 0 and 3 and at positions 2 and 4. -2 appears only once.
Example 2
Input: nums = [-4,9,9,-4,12,3,3]
Output: 12
Example 3
Input: nums = [0,13,-8,13,-8]
Output: 0
Constraints
1 ≤ nums.length < 3 × 10⁵-10⁹ ≤ nums[i] ≤ 10⁹- One value appears exactly once in
nums, and every other value appears exactly twice
Solve it here
Write it in Python, Java or C++, run it on your own cases, and submit against hidden tests.
Practice this in an AI round
30 minutes on this problem with an AI agent beside your code, then a report on your solution and how you used the agent.
See the AI roundWatch the explanation
More Bit Manipulation
- Add BinaryAI round · Easy
- Single Number IIAI round · Medium
- Single Number IIIAI round · Medium
- Power of TwoEasy
- Number of 1 BitsEasy