LeetCode 27 Remove Element
概述
https://leetcode.com/problems/remove-element/
快慢指针
class Solution {
public:
int removeElement(vector<int>& nums, int val) {
int s, f;
for (s = 0, f = 0; f < nums.size(); f ++) {
if (nums[f] != val) {
nums[s++] = nums[f];
}
}
return s;
}
};
Links: leetcode-27-remove-element