leetcode 27 Remove Element

class Solution {
public:
    int removeElement(vector<int>& nums, int val) {
        int res = 0;
        for (int i = 0; i < nums.size(); ++i) {
            if (nums[i] != val) nums[res++] = nums[i];
        }
        return res;
    }
};
posted @ 2017-02-11 23:59  王坤1993  阅读(125)  评论(0编辑  收藏  举报