美文网首页
26. Remove Duplicates from Sorte

26. Remove Duplicates from Sorte

作者: 夜皇雪 | 来源:发表于2016-12-12 15:00 被阅读0次
public class Solution {
    public int removeDuplicates(int[] nums) {
        if(nums.length==0||nums.length==1) return nums.length;
        int count=1;
        for(int i=1;i<nums.length;i++){
            if(nums[i-1]!=nums[i]) nums[count++]=nums[i];
        }
        return count;
    }
}

相关文章

网友评论

      本文标题:26. Remove Duplicates from Sorte

      本文链接:https://www.haomeiwen.com/subject/fkvmmttx.html