Skip to content

Commit

Permalink
Solve: Remove Element
Browse files Browse the repository at this point in the history
  • Loading branch information
fkdl0048 committed Oct 4, 2024
1 parent 4bc1442 commit a7ec631
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions LeetCode/Remove Element.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class Solution {
public:
int removeElement(vector<int>& nums, int val) {
int j = 0;
for (int i = 0; i < nums.size(); i++){
if (nums[i] != val) {
nums[j] = nums[i];
j++;
}
}

return j;
}
};

0 comments on commit a7ec631

Please sign in to comment.