@@ -0,0 +1,990 @@
+/**%0A * Problem: #26 Remove Duplicates from Sorted Array%0A *%0A * Idea: One point to count numbers of elements to delete, the other is for the current%0A * position to store the values that are not going to be deleted.%0A *%0A * Solutions:%0A *  removeElement: two pointers%0A */%0A%0Apublic class RemoveDuplicatesFromSortedArray %7B%0A    public int removeDuplicates(int%5B%5D nums) %7B%0A        if (nums.length == 0) return 0;%0A%0A        int currentPosition = 1;%0A        int currentValue = nums%5B0%5D;%0A        for (int i = 0; i %3C nums.length; i++) %7B%0A            if (nums%5Bi%5D != currentValue) %7B%0A                nums%5BcurrentPosition%5D = nums%5Bi%5D;%0A                currentPosition ++;%0A                currentValue = nums%5Bi%5D;%0A            %7D%0A        %7D%0A        return currentPosition;%0A    %7D%0A%0A/*    public static void main(String%5B%5D args) %7B%0A        int%5B%5D array = new int%5B%5D %7B1,1,2%7D;%0A        System.out.println(new RemoveDuplicatesFromSortedArray().removeDuplicates(array));%0A        System.out.println(Arrays.toString(array));%0A    %7D*/%0A%7D%0A

Add new solution