class Solution {
public:
int removeElement(int A[], int n, int elem) {
if(n==0)
return 0;
for(int i = n-1; i>=0; --i)
{
if(elem==A[i])
{
for(int j = i; j < n-1; ++j)
{
A[j] = A[j+1];
}
n--;
}
}
return n;
}
};
leetcode Remove Element
最新推荐文章于 2024-02-23 09:08:20 发布
