@@ -0,0 +1,1575 @@
+/**%0A * Given an array of integers where 1 %E2%89%A4 a%5Bi%5D %E2%89%A4 n (n = size of array), %0A * some elements appear twice and others appear once.%0A * Find all the elements of %5B1, n%5D inclusive that do not appear in this array.%0A * There is an O(N) space solution and an O(1) space solution.%0A * Both run in O(N) time.%0A */%0Apublic class Solution %7B%0A%0A  // This is the O(N) space solution%0A  public List%3CInteger%3E findDisappearedNumbers(int%5B%5D nums) %7B%0A    // Use another array to keep track of what's been seen.%0A    int%5B%5D temp = new int%5Bnums.length%5D;%0A    for (int i = 0; i %3C nums.length; i ++) %0A      temp%5Bnums%5Bi%5D - 1%5D ++;%0A%0A    List%3CInteger%3E res = new ArrayList%3CInteger%3E();%0A    for (int i = 0; i %3C temp.length; i ++) %0A%0A      // Any index that has a value greater than one means it has been seen.%0A      // The exact value shows how many hits it has received.%0A      if (temp%5Bi%5D == 0) res.add(i +  1);%0A%0A    return res;%0A  %7D%0A%0A  // This is the O(1) space solution.%0A  public List%3CInteger%3E findDisappearedNumbers(int%5B%5D nums) %7B%0A    for (int i = 0; i %3C nums.length; i ++) %7B%0A      int index = Math.abs(nums%5Bi%5D) - 1;%0A      // Only mark once as multiplying two negatives makes it positive,%0A      // therefore visiting an even number of times would make it seem unvisited.%0A      if (nums%5Bindex%5D %3E 0) %0A        // Mark as visited by making it negative%0A        nums%5Bindex%5D = -1 * nums%5Bindex%5D;%0A    %7D%0A%0A    List%3CInteger%3E res = new ArrayList%3CInteger%3E();%0A    for (int i = 0; i %3C nums.length; i ++) %7B%0A      // Any non-negative means it has not been visited.%0A      if (nums%5Bi%5D %3E 0) res.add(i +  1);%0A    %7D%0A%0A    return res;%0A  %7D%0A%7D%0A

Add 448