leetcode 27 Remove Element

2018-06-04 12:35:01 浏览数 (1)

代码语言:javascript复制
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;
    }
};

0 人点赞