class Solution {
public:
int removeElement(int A[], int n, int elem) {
int length=n;
for(int i=0;i<n&&i<length;i++){
if(A[i]==elem){
swap(A[i],A[length-1]);
length--;
i--;
}
}
return length;
}
};
LeetCode - 27 Remove Element
最新推荐文章于 2015-08-16 19:23:30 发布