@@ -0,0 +1,1153 @@
+/*%0A Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array.%0A%0AFor example,%0AGiven nums = %5B0, 1, 3%5D return 2.%0A%0ANote:%0AYour algorithm should run in linear runtime complexity. Could you implement it using only constant extra space complexity? %0A*/%0A%0Aimport java.util.*;%0A%0Apublic class MissingNumber %7B%0A%09public static int missingNumber(int%5B%5D nums) %7B%0A        if(nums.length %3C= 0) return 0;%0A        int L = nums.length;%0A        int p = 0;%0A        int i;%0A        for(i = 0; i %3C L; i++)%7B%0A            while(nums%5Bi%5D %3C L && nums%5Bi%5D != i)%7B%0A                p = nums%5Bnums%5Bi%5D%5D;%0A                nums%5Bnums%5Bi%5D%5D = nums%5Bi%5D;%0A                nums%5Bi%5D = p;%0A            %7D%0A        %7D%0A        for(i =0; i %3C L; i++)%7B%0A            if(nums%5Bi%5D != i) return i;%0A        %7D%0A        return i;%0A    %7D%0A%09%0A%09public static void main(String%5B%5D args) %7B%0A%09%09int%5B%5D nums1 = new int%5B%5D %7B1, 4, 2, 3%7D;%0A        System.out.println(%22Array: %22);%0A%09%09for(int i=0; i %3C nums1.length; i++)%7B%0A%09%09%09System.out.print(nums1%5Bi%5D + %22 %22);%0A%09%09%7D%0A        System.out.println();%0A%09%09int res = missingNumber(nums1);%0A        System.out.println(%22Missing number: %22 + res);%0A%09%09return;%0A%09%7D%09%0A%7D%0A

missing number