Skip to content

Commit 16bd68f

Browse files
authored
Merge pull request Dijkstra-Edu#1 from VISHAL3003/vishal-patch-1
Commit 122 - Added remove element in cpp - 16.02.2024
2 parents 0d64fa6 + 701e217 commit 16bd68f

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed
File renamed without changes.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class Solution {
2+
public:
3+
int removeElement(vector<int>& nums, int val) {
4+
nums.erase(
5+
std::remove(
6+
nums.begin(),
7+
nums.end(),
8+
val),
9+
nums.end());
10+
return nums.size();
11+
}
12+
};
13+
14+
/*
15+
TC - O(n + k)
16+
SC - O(1)
17+
*/
File renamed without changes.

0 commit comments

Comments
 (0)