标签:
public class Solution { public int removeDuplicates(int[] A) { if(A==null || A.length==0) return 0; // 巧妙的做法http://www.cnblogs.com/springfor/p/3871038.html int len =0; // 记录最后一个不重复的点在新数组中位置,尾端 for(int i=1; i<A.length;i++){ if(A[i]!=A[i-1]){ if(A[i]!=A[len]){ A[len+1] = A[i]; len++; } } } return len+1; } }
Remove Duplicates from Sorted Array
标签:
原文地址:http://www.cnblogs.com/jiajiaxingxing/p/4414283.html