Single Number III
Medium Bit Manipulation
nums is a list of whole numbers.
Two values in nums appear only once each, and every other value appears exactly twice.
Return the two values that appear once, in either order.
Example 1
Input: nums = [7,-2,9,7,4,9]
Output: [-2,4]
7 and 9 appear twice each, so -2 and 4 are the two that appear once; [4, -2] is right too.
Example 2
Input: nums = [0,6]
Output: [0,6]
Example 3
Input: nums = [-5,8,-5,8,11,-13]
Output: [-13,11]
Constraints
2 ≤ nums.length ≤ 3 × 10⁵-2³¹ ≤ nums[i] ≤ 2³¹ - 1- Exactly two values appear once in
nums, and every other value 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
- Single NumberAI round · Very easy
- Add BinaryAI round · Easy
- Single Number IIAI round · Medium
- Power of TwoEasy
- Number of 1 BitsEasy