leetcode Remove Duplicates from Sorted Array II

来源:互联网 发布:智云软件开发 编辑:程序博客网 时间:2024/06/15 08:04

题目链接

思路:
没有

public class Solution {    public int removeDuplicates(int[] nums) {       int length=1;        boolean exist=false;        int distance=0;        for(int i=1;i<nums.length;i++)        {            if(nums[i-1-distance]==nums[i])            {                if(exist)                {                    distance++;                    continue;                }                else                {                    exist=true;                }            }            else            {                exist=false;            }            length++;            nums[i-distance]=nums[i];        }        return length;    }}
0 0
原创粉丝点击