删除排序数组中的重复数字 - Java

public class Solution {
    /**
     * @param A: a array of integers
     * @return : return an integer
     */
    public int removeDuplicates(int[] nums) {
        // write your code here
    int i,j=0,l;
    l=nums.length;
    if(l==0)
    {
        return l;
    }
    else for(i=1;i<l;i++)
    {
            if(nums[i]!=nums[j])
            {
               nums[++j]=nums[i];  
            }
    }
     return j+1;  
    }
}

posted @ 2017-03-08 21:32  陌路站台  阅读(1743)  评论(0编辑  收藏  举报