Remove Element

题目链接https://leetcode.com/problems/remove-element/

这道题比较简单,为了维护这个leetcode系列的完整性,我依然把它加在这里,code如下

class Solution {
public:
    int removeElement(int A[], int n, int elem) {
        for(int i = 0; i < n; i++) {
            if(A[i] == elem) {
                A[i] = A[n - 1];
                n--;
                i--;
            }
        }
        return n;
    }
};
原文地址:https://www.cnblogs.com/walcottking/p/4430807.html