1 class Solution {
 2 public:
 3     int removeElement(int A[], int n, int elem) {
 4         int index = 0;
 5         for (int i = 0; i < n; i++) {
 6             if (A[i] != elem) {
 7                 A[index++] = A[i];
 8             }
 9         }
10         return index;
11     }
12 };

 

posted on 2015-03-22 17:00  keepshuatishuati  阅读(120)  评论(0编辑  收藏  举报