package com.fishercoder.solutions;

/**Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array.

 For example,
 Given nums = [0, 1, 3] return 2.

 Note:
 Your algorithm should run in linear runtime complexity. Could you implement it using only constant extra space complexity?*/

public class _268 {

    /**we could take advantage of the array indices
    then a number xor with itself is zero, so after we xor the entire array with all of its indices, the missing number will show up.*/
    public int missingNumber(int[] nums) {
        int xor = 0;
        int i = 0;
        for (; i < nums.length; i++) {
            xor = xor ^ i ^ nums[i];
        }
        return xor ^ i;
    }

}

@@ -33,341 +33,88 @@
 s;%0A%0A
-/**Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array.%0A%0A For example,%0A Given nums = %5B0, 1, 3%5D return 2.%0A%0A Note:%0A Your algorithm should run in linear runtime complexity. Could you implement it using only constant extra space complexity?*/%0A%0Apublic class _268 %7B%0A%0A
+public class _268 %7B%0A%0A    public static class Solution1 %7B%0A        /**%0A     
     
-/*
 *
+ 
 we c
@@ -157,16 +157,23 @@
 ices%0A   
+      *
  then a 
@@ -298,11 +298,25 @@
  up.
-*/%0A
+%0A         */%0A    
     
@@ -358,24 +358,28 @@
 ) %7B%0A        
+    
 int xor = 0;
@@ -383,24 +383,28 @@
  0;%0A        
+  
+  
 int i = 0;%0A 
@@ -410,16 +410,20 @@
         
+   
+ 
 for (; i
@@ -441,24 +441,28 @@
 gth; i++) %7B%0A
+    
             
@@ -498,18 +498,25 @@
     
-%7D%0A
+    %7D%0A   
         
 retu
@@ -511,16 +511,17 @@
         
+ 
 return x
@@ -528,16 +528,26 @@
 or %5E i;%0A
+        %7D%0A
     %7D%0A%0A%7D

refactor 268