首页 > 其他 > 详细

LeetCode-Remove Duplicates From Sorted Array

时间:2015-06-15 21:45:33      阅读:187      评论:0      收藏:0      [点我收藏+]

descriptions:

Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.

注意是有序数组。。

代码:

if(nums.length==0) return 0;

int flag=1;

for(int i=1;i<nums.length;i++){

if(nums[i-1]==nums[i]) 

{

continue;

}else{

nums[flag]=nums[i];

flag++;

}

}

return flag;

LeetCode-Remove Duplicates From Sorted Array

原文:http://www.cnblogs.com/hhhhh/p/4579090.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!