Single Number II
Medium Bit Manipulation
nums is a list of whole numbers.
Every value in nums appears exactly three times, except one value, which appears only once.
Return the value that appears once.
Example 1
Input: nums = [5,-4,5,9,-4,5,-4]
Output: 9
5 and -4 each appear three times, 5 at places 0, 2 and 5 and -4 at places 1, 4 and 6; 9 appears once.
Example 2
Input: nums = [0,7,0,0]
Output: 7
Example 3
Input: nums = [-8,-8,13,-8]
Output: 13
Constraints
1 ≤ nums.length < 3 × 10⁵-2³¹ ≤ nums[i] ≤ 2³¹ - 1- One value appears exactly once in
nums, and every other value exactly three times
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 IIIAI round · Medium
- Power of TwoEasy
- Number of 1 BitsEasy