标签:style class blog code color os
class Solution { public: int removeElement(int A[], int n, int elem) { if (A == NULL || n < 1) return 0; int rpos = 0, wpos = 0; int removed = 0; while (rpos < n) { if (A[rpos] == elem) { rpos++; removed++; } else { A[wpos++] = A[rpos++]; } } return n - removed; } };
再水
LeetCode Remove Element,布布扣,bubuko.com
标签:style class blog code color os
原文地址:http://www.cnblogs.com/lailailai/p/3806063.html