您的位置:首页 > 其它

leetcode Remove Duplicates from Sorted Array II

2015-10-22 19:39 337 查看
题目链接

思路:

没有

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;
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: