[LeetCode]移除元素
题目
代码
class Solution {
public:
int removeElement(vector<int>& nums, int val) {
int i = 0, j = 0;
while(j != nums.size())
{
if(nums[j]!= val)
{
nums[i]=nums[j];
i++;
}
j++;
}
return i;
}
};
https://github.com/li-zheng-hao