MCPcopy Create free account
hub / github.com/Hsinha11/Leetcode-solutions / removeElement

Method removeElement

27-Remove-Element/27-Remove-Element.cpp:3–15  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1class Solution {
2public:
3 int removeElement(std::vector<int>& nums, int val) {
4 int k = 0;
5
6 for (int i = 0; i < nums.size(); ++i) {
7 if (nums[i] != val) {
8 nums[k] = nums[i];
9 ++k;
10 }
11 }
12
13
14 return k;
15 }
16};

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected