首页 > 代码库 > 【leetcode】Remove Duplicates from Sorted Array

【leetcode】Remove Duplicates from Sorted Array

  int removeDuplicates(int A[], int n) {
        if(n <= 1)
        return n;
        int newIndex = 0;
        for(int i = 1; i < n; ++i){
            if(A[i] != A[newIndex])
            A[++newIndex] = A[i];
        }
        return ++newIndex; 
    }