diff --git a/LeetCode/Remove Element.cpp b/LeetCode/Remove Element.cpp new file mode 100644 index 0000000..54500fb --- /dev/null +++ b/LeetCode/Remove Element.cpp @@ -0,0 +1,14 @@ +class Solution { +public: + int removeElement(vector& 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; + } +}; \ No newline at end of file