@@ -0,0 +1,617 @@
+// 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%09%09int len = A.length;%0A%0A%09%09if(len %3C 3) return len;%0A%0A%09%09int fast = 1;%0A%09%09int slow = 0;%0A%09%09int counter = 1;%0A%0A%09%09while(fast %3C len)%7B%0A%09%09%09if(A%5Bfast%5D == A%5Bslow%5D)%7B%0A%09%09%09%09if(counter %3E= 2)%7B%0A%09%09%09%09%09fast++;%0A%09%09%09%09%7Delse%7B%0A%09%09%09%09%09counter++;%0A%09%09%09%09%09A%5B++slow%5D = A%5Bfast++%5D;%0A%09%09%09%09%7D%0A%09%09%09%7Delse%7B%0A%09%09%09%09counter = 1;%0A%09%09%09%09A%5B++slow%5D = A%5Bfast++%5D;%0A%09%09%09%7D%0A%09%09%7D%0A%0A%09%09return ++slow;%0A    %7D%0A%7D

add remove duplicates from sorted array ii solution