Simple java solution


  • 0
    S

    public boolean containsDuplicate(int[] nums) {
    Arrays.sort(nums);
    int i=0,j=1;
    while(i<j&&j<nums.length){
    if(nums[i]==nums[j])
    return true;
    i++;
    j++;
    }
    return false;
    }


Log in to reply
 

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