@@ -0,0 +1,1074 @@
+package main.algorithm.leetcode;%0A%0Aimport org.junit.Test;%0A%0A/**%0A * Title : main.algorithm.leetcode %3Cbr%3E%0A * Company : %E5%8C%97%E4%BA%AC%E5%8D%8E%E5%AE%87%E5%85%83%E5%85%B8%E4%BF%A1%E6%81%AF%E6%9C%8D%E5%8A%A1%E6%9C%89%E9%99%90%E5%85%AC%E5%8F%B8 %3Cbr%3E%0A * Description :%0A *%0A *%0A * @author chile%0A * @version 1.0%0A * @date 2019/4/29 9:49%0A */%0Apublic class RemoveDuplicatesfromSortedArray %7B%0A%0A    class Solution %7B%0A        public int removeDuplicates(int%5B%5D nums) %7B%0A            if (nums.length == 0) %7B%0A                return 0;%0A            %7D%0A%0A            int i = 0;%0A            for (int j = 1; j %3C nums.length; j++) %7B%0A                if (nums%5Bj%5D %3E nums%5Bi%5D) %7B%0A                    nums%5B++i%5D = nums%5Bj%5D;%0A                %7D%0A            %7D%0A%0A            return i + 1;%0A        %7D%0A    %7D%0A%0A    @Test%0A    public void test1() %7B%0A        int%5B%5D nums = %7B1, 2%7D;%0A        assert new Solution().removeDuplicates(nums) == 2;%0A        for (int i : nums) %7B%0A            System.out.print(i);%0A        %7D%0A    %7D%0A%0A    @Test%0A    public void test2() %7B%0A        int%5B%5D nums = %7B1, 1, 2, 2, 4, 5, 6, 6%7D;%0A        assert new Solution().removeDuplicates(nums) == 5;%0A        for (int i : nums) %7B%0A            System.out.print(i);%0A        %7D%0A    %7D%0A%0A%7D%0A

Remove Duplicates from Sorted Array