java easy solution for 164. Maximum Gap--7 lines,4ms


  • -1
    X
    public int maximumGap(int[] nums) {
        int max=0;
        if(nums.length<2|| nums==null) return 0;
     Arrays.sort(nums);
    

    for(int i=0; i<nums.length-1;i++){
    max=Math.max(max,nums[i+1]-nums[i]);
    } return max;
    }


Log in to reply
 

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