您的位置:首页 > 其它

leetcode Remove Duplicates from Sorted Array |

2014-11-05 15:34 316 查看
Remove Duplicates from Sorted Array |

代码

class Solution {
public:
int removeDuplicates(int A[], int n) {

int cnt = 0;

if(n==0)
return 0;

cnt++;
for(int i = 1; i < n; i++)
{
if(A[i]!=A[i-1])
{
A[cnt] = A[i];
cnt++;
}
}

return cnt;

}
};



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