I am using bubbleSort beating 2% players


  • -1
    D
    public int findDuplicate(int[] nums) {
        for(int i = 0 ; i < nums.length ; i++)
            for(int j = i+ 1 ; j < nums.length ; j++){
                if(nums[i] == nums[j]) return nums[i];
            }
        
        return -1;
    }

Log in to reply
 

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