@@ -0,0 +1,1600 @@
+/**%0A *%09Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.%0A *%0A *%09Do not allocate extra space for another array, you must do this in place with constant memory.%0A *%0A *%09For example,%0A *%09Given input array nums = %5B1,1,2%5D,%0A *%0A *%09Your function should return length = 2, with the first two elements of nums being 1 and 2 respectively.%0A *%09It doesn't matter what you leave beyond the new length.%0A *%0A *%09Author: matao%0A *%0A */%0A%0Apublic class RemoveDuplicatesFromSortedArray %7B%0A%09public static int removeDuplicates(int%5B%5D nums) %7B%0A     %09if(nums == null %7C%7C nums.length == 0) %7B%0A     %09%09return 0;%0A     %09%7D   %0A%0A     %09int count = 0;%0A     %09for(int i = 0; i %3C nums.length; i++) %7B%0A     %09%09if(nums%5Bi%5D != nums%5Bcount%5D) %7B%0A     %09%09%09nums%5B++count%5D = nums%5Bi%5D;%0A     %09%09%7D%0A     %09%7D%0A     %09return count+1;%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A    %09int%5B%5D nums1 = %7B1, 1, 2%7D;%0A    %09System.out.println(removeDuplicates(nums1));%0A%0A    %09int%5B%5D nums2 = %7B1%7D;%0A    %09System.out.println(removeDuplicates(nums2));%0A%0A    %09int%5B%5D nums3 = %7B1, 1, 2, 2%7D;%0A    %09System.out.println(removeDuplicates(nums3));%0A%0A    %09int%5B%5D nums4 = %7B1, 1, 2, 2, 2, 3%7D;%0A    %09System.out.println(removeDuplicates(nums4));%0A%0A    %09int%5B%5D nums5 = %7B-14,-14,-13,-13,-13,-13,-13,-13,-13,-12,-12,-12,-12,-11,-10,-9,-9,-9,-8,-7,-5,-5,-5,-5,-4,-3,-3,-2,-2,-2,-2,-1,-1,-1,-1,-1,0,1,1,1,1,2,2,2,3,3,3,4,4,4,4,5,5,5,6,6,6,6,7,8,8,8,9,9,9,10,10,10,11,11,11,12,12,12,13,14,14,14,14,15,16,16,16,18,18,18,19,19,19,19,20,20,20,21,21,21,21,21,21,22,22,22,22,22,23,23,24,25,25%7D;%0A    %09System.out.println(removeDuplicates(nums5));%0A    %7D%0A%7D

add Remove Duplicates From Sorted Array solution