美文网首页
80. Remove Duplicates from Sorte

80. Remove Duplicates from Sorte

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

相关文章

网友评论

      本文标题:80. Remove Duplicates from Sorte

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