nlogn+1 4line C++


  • 0
    S

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


Log in to reply
 

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