标签:style blog color io ar sp div c on
/* put all vaild new array from the 0 to new length */ public class Solution { public int removeDuplicates(int[] A) { if(A.length < 2) return A.length; int j = 0; int i = 1; while(i < A.length){ if(A[i] == A[j]){ i++; }else{ A[++j] = A[i++]; } } return j+1; } }
神小逻辑 Remove Duplicates from Sorted Array
标签:style blog color io ar sp div c on
原文地址:http://www.cnblogs.com/leetcode/p/4008959.html