@@ -0,0 +1,992 @@
+/***%0A * Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.%0A *%0A * Do not allocate extra space for another array, you must do this in place with constant memory.%0A *%0A * For example,%0A * Given input array A = %5B1,1,2%5D,%0A *%0A * Your function should return length = 2, and A is now %5B1,2%5D.%0A */%0Apublic class Solution %7B%0A    // Solution 1:%0A    /*%0A    public int removeDuplicates(int%5B%5D A) %7B%0A        if (A.length == 0)%0A            return 0;%0A        int j = 1;%0A        for (int i = 1; i %3C A.length; i++)%0A            if (A%5Bi - j%5D == A%5Bi%5D)%0A                j++;%0A            else%0A                A%5Bi - j + 1%5D = A%5Bi%5D;%0A        return A.length - j + 1;%0A    %7D%0A    */%0A    // Solution 2:%0A    public int removeDuplicates(int%5B%5D A) %7B%0A        if (A.length == 0)%0A            return 0;%0A        int index = 0;%0A        for (int i = 1; i %3C A.length; i++)%0A            if (A%5Bindex%5D != A%5Bi%5D)%0A                A%5B++index%5D = A%5Bi%5D;%0A        return index + 1;%0A    %7D%0A%0A%7D%0A

add RemoveDuplicatesfromSortedArray.java