@@ -0,0 +1,777 @@
+/***%0A * Follow up for %22Remove Duplicates%22:%0A * What if duplicates are allowed at most twice?%0A *%0A * For example,%0A * Given sorted array A = %5B1,1,1,2,2,3%5D,%0A *%0A * Your function should return length = 5, and A is now %5B1,1,2,2,3%5D.%0A */%0Apublic class Solution %7B%0A    public int removeDuplicates(int%5B%5D A) %7B%0A        if (A.length == 0)%0A            return 0;%0A        int index = 0;%0A        int counter = 1;%0A        for (int i = 1; i %3C A.length; i++) %7B%0A            if (A%5Bi%5D != A%5Bindex%5D) %7B%0A                index++;%0A                A%5Bindex%5D = A%5Bi%5D;%0A                counter = 1;%0A            %7D else if (counter == 1) %7B%0A                index++;%0A                A%5Bindex%5D = A%5Bi%5D;%0A                counter++;%0A            %7D else %0A                counter = 0;%0A        %7D%0A        return index + 1;%0A    %7D%0A%7D%0A

add RemoveDuplicatesfromSortedArrayII.java