Search
 
SCRIPT & CODE EXAMPLE
 

CPP

136. Single Number leetcode solution in c++

class Solution {
public:
    int singleNumber(vector<int>& nums) {
        int n;
        if(nums.size()==1)
            return nums[0];
        
        sort(nums.begin(),nums.end());
        
        for(int i=0;i<nums.size();i++)
        {
            if(nums[i]==nums[i+1])
            {
                i++;
            }else 
            {
                n=nums[i];
            }
        }
        
        return n;
    }
};
Comment

PREVIOUS NEXT
Code Example
Cpp :: Arduino C++ servomotor random moving 
Cpp :: c++ konsolenausgabe 
Cpp :: c++ start thread later 
Cpp :: print the elements of the array without using the [] notation in c++ 
Cpp :: c+ 
Cpp :: C++ Function-style Casting 
Cpp :: break input stream into words 
Cpp :: No Index Out of Bound Checking in C++ 
Cpp :: leetcode 36 c++ 
Cpp :: declare static table filled cpp 
Cpp :: composition namespaces c++ 
Cpp :: cpp-variadics/problem? 
Cpp :: how the theam are store in database 
Cpp :: why do men drink liquor 
Cpp :: how to make a substring after certain position 
Cpp :: cpp console progressbar 
Cpp :: map update field elixir 
Cpp :: Magical Doors codechef solution in c++ 
Cpp :: lambda - print-out array and add comment 
Cpp :: c++ power operator 
Cpp :: c++ how to print out 
Cpp :: how to calculate the sum of primary diagonal matrix and secondary diagonal matrix using c++ 
Cpp :: c++ max function 
Cpp :: c++ & operator 
Cpp :: Set Specific Time in youtube Video url 
Cpp :: c++ copy string 
Cpp :: char * to string c++ 
C :: c colour text 
C :: .gitkeep file 
C :: disable lua errors 
ADD CONTENT
Topic
Content
Source link
Name
7+5 =