@@ -0,0 +1,1801 @@
+package org.pilgrim.leetcode.y2021;%0A%0A/*Given an array nums containing n distinct numbers in the range %5B0, n%5D, return the only number in the range that is missing from the array.%0A%0AFollow up: Could you implement a solution using only O(1) extra space complexity and O(n) runtime complexity?%0A%0A %0A%0AExample 1:%0A%0AInput: nums = %5B3,0,1%5D%0AOutput: 2%0AExplanation: n = 3 since there are 3 numbers, so all numbers are in the range %5B0,3%5D. 2 is the missing number in the range since it does not appear in nums.%0AExample 2:%0A%0AInput: nums = %5B0,1%5D%0AOutput: 2%0AExplanation: n = 2 since there are 2 numbers, so all numbers are in the range %5B0,2%5D. 2 is the missing number in the range since it does not appear in nums.%0AExample 3:%0A%0AInput: nums = %5B9,6,4,2,3,5,7,0,1%5D%0AOutput: 8%0AExplanation: n = 9 since there are 9 numbers, so all numbers are in the range %5B0,9%5D. 8 is the missing number in the range since it does not appear in nums.%0AExample 4:%0A%0AInput: nums = %5B0%5D%0AOutput: 1%0AExplanation: n = 1 since there is 1 number, so all numbers are in the range %5B0,1%5D. 1 is the missing number in the range since it does not appear in nums.%0A %0A%0AConstraints:%0A%0An == nums.length%0A1 %3C= n %3C= 104%0A0 %3C= nums%5Bi%5D %3C= n%0AAll the numbers of nums are unique.*/%0A%0Apublic class MissingNumber %7B%0A    public int missingNumber(int%5B%5D nums) %7B%0A        if(nums == null)%7B%0A            return -1;%0A        %7D%0A        %0A        int n = nums.length;%0A        %0A        //sort%0A        for(int i=0; i%3Cn; i++)%7B%0A            int k = nums%5Bi%5D;%0A            %0A            while(k != i && k != n)%7B%0A                nums%5Bi%5D = nums%5Bk%5D;%0A                nums%5Bk%5D = k;%0A                k = nums%5Bi%5D;%0A            %7D%0A        %7D%0A        %0A        for(int i=0; i%3Cn; i++)%7B%0A            int k = nums%5Bi%5D;%0A            if(k == n)%7B%0A                return i;%0A            %7D%0A        %7D%0A        %0A        return n;%0A    %7D%0A%7D

add MissingNumber