Single Number
Very easy Bit Manipulation AI round
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
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.
Your first AI round is free.
Watch the explanation
More Bit Manipulation
- Add BinaryAI round · Easy
- Single Number IIAI round · Medium
- Power of TwoEasy
- Number of 1 BitsEasy
- Single Number IIIMedium