码迷,mamicode.com
首页 > 其他好文 > 详细

LeetCode-Remove Duplicates From Sorted Array

时间:2015-06-15 21:48:16      阅读:116      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!