15 lines
250 B
C++
15 lines
250 B
C++
#include "s0027_remove_element.hpp"
|
|
|
|
int S0027::removeElement(vector<int>& nums, int val) {
|
|
int len = nums.size();
|
|
int f{0}, s{0};
|
|
while (f < len) {
|
|
if (nums[f] != val) {
|
|
nums[s] = nums[f];
|
|
++s;
|
|
}
|
|
++f;
|
|
}
|
|
return s;
|
|
}
|