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

remove duplicates from sorted array