22ms c++ bitmap solution


  • 0
    bool containsDuplicate(vector<int>& nums) {
        if(nums.size()<2)return false;
        
        int check[223323232>>8];
        memset(check,0,sizeof(check));
        for(n:nums){
            if((check[n/32]&1<<(n%32))>0)return true;
            check[n/32]|=1<<(n%32);
        }
        return false;
    }

  • 0
    Y

    can u explain ur code? I dont know how it work ...


Log in to reply
 

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