Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- public:
- int singleNumber(vector<int>& nums) {
- unordered_map<int,int> m;
- for(int i=0;i<nums.size();i++)
- {
- m[nums[i]]++;
- }
- int ans;
- for(auto u:m)
- {
- if(u.second==1)
- {
- ans=u.first;
- break;
- }
- }
- return ans;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment