225. Single Number - II

Given an array nums where each integer in nums appears thrice except one. Find out the number that has appeared only once.

Example 1:

Input : nums = [2, 2, 2, 3]

Output : 3

Explanation : The integers 3 has appeared only once.

Example 2:

Input : nums = [1, 0, 3, 0, 1, 1, 3, 3, 10, 0]

Output : 10

Explanation : The integers 10 has appeared only once.

Now Your Turn!

Pick the correct output for the given input

Input : nums = [5, 0, 1, 10, 1, 1, 5, 5, 10, 10]

Still unsure what the problem is asking ?

Let’s go through a few more examples, step by step, to make it clearer.

Constraints:

  • 1 <= n <= 3*104
  • -231 <= nums[i] <= 231 - 1

Hints

Frequently Occurring Doubts

Interview Follow-up Questions

Fun Facts

0
class Solution {
public:
int singleNumber(vector<int>& nums) {
//your code goes here
}
};
Test Case

Input:

Nums