class Solution {
public:
int removeElement(vector<int>& nums, int val) {
int k=0;
vector<int> index;
for(auto iter=nums.begin();iter!=nums.end();iter++)
{
if(*iter!=val)
{
index.push_back(*iter);
k++;
}
}
nums=index;
return k;
}
};
'Coding Test > LeetCode' 카테고리의 다른 글
26. Remove Duplicates from Sorted Array (0) | 2023.08.08 |
---|---|
80. Remove Duplicates from Sorted Array II (0) | 2023.08.08 |
88. Merge Sorted Array (0) | 2023.08.07 |