c++ set


  • 0
    D

    class Solution {
    public:
    bool containsDuplicate(vector<int>& nums) {
    int size=nums.size();
    set<int> p;

        for(int i=0;i<size;i++)
        {
            if(p.count(nums[i]))
                return true;
            else
                p.insert(nums[i]);
        }
        return false;
    }
    

    };


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.