class Solution {

public:

int singleNumber(vector<int>& nums) {

sort(nums.begin(),nums.end());

int i=0;

int temp=nums[i];

int count=1;

for(i=1;i<nums.size();i++)

{

if(nums[i]==temp)

count++;

else

{

temp=nums[i];

if(count!=3)

break;

else

count=1;

}

```
}
return nums[i-1];
}
```

};