Why this problem is rated as a medium difficulty?


  • -5
    H
      public int missingNumber(int[] nums) {
            int sum=(nums.length+1)*(nums.length)/2;
            for(int i=0; i<nums.length; i++){
                sum-=nums[i];
            }
            return sum;
        }

Log in to reply
 

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