您的位置:首页 > 其它

LeetCode之Remove Duplicates from Sorted Array

2014-04-14 23:03 232 查看
int removeDuplicates(int A[], int n) //Remove Duplicates from Sorted Array
{
if (n == 0) return 0;
int index = 0;
for (int i = 1; i < n; i++) {
if (A[index] != A[i])
A[++index] = A[i];
}
return index + 1;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息