26. Remove Duplicates from Sorted Array徒手尝试#1(Done)

来源:互联网 发布:编程小白学 python 编辑:程序博客网 时间:2024/06/17 00:02

Solution

public class Solution {    public int removeDuplicates(int[] nums) {        if(nums == null || nums.length == 0) return 0;        if(nums.length == 1) return 1;        int n = nums[0];        int len = 1;        for(int i = 1; i < nums.length; i++) {            if(n != nums[i]) {                n = nums[i];                nums[len++] = n;            }        }        return len;    }}

Problem

0 0
原创粉丝点击