美文网首页
26. Remove Duplicates from Sorte

26. Remove Duplicates from Sorte

作者: wtmxx | 来源:发表于2018-02-09 23:01 被阅读0次
class Solution {
    public int removeDuplicates(int[] nums) {
        if(nums.length<=1)return nums.length;
        int count = 1;
        for(int i=1;i<nums.length;i++){
            if(nums[i]!=nums[i-1]){
                nums[count] = nums[i];
                count++;
            }
        }
        return count;
    }
}

相关文章

网友评论

      本文标题:26. Remove Duplicates from Sorte

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