标签:
题目链接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; } };
标签:
原文地址:http://www.cnblogs.com/walcottking/p/4430807.html