[Leetcode]-- Remove Duplicates from Sorted Array

 

public class Solution {
    public int removeDuplicates(int[] A) {
        if(A.length == 0) 
            return 0;
            
        int count = 1;
        
        for(int i = 1; i < A.length; i++){
            if(A[i-1] == A[i])
                continue;
                
            A[count++] = A[i];
        }
        
        return count;
    }
}

 

posted @ 2014-02-06 13:29  Razer.Lu  阅读(145)  评论(0编辑  收藏  举报