Skip to content

Commit 60febdc

Browse files
committed
Time: 6 ms (26.85%), Space: 8.9 MB (35.10%) - LeetHub
1 parent ab85773 commit 60febdc

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#include <bits/stdc++.h>
2+
class Solution {
3+
public:
4+
int removeElement(vector<int>& arr, int val) {
5+
int size = 0;
6+
int j = 0;
7+
for(int i=0; i<arr.size(); i++)
8+
{
9+
// cout<<arr[i]<<" ";
10+
if(arr[i] != val)
11+
{
12+
cout<<arr[i]<<" " <<i <<endl;
13+
arr[j] = arr[i];
14+
size+=1;
15+
j+=1;
16+
}
17+
}
18+
return size;
19+
}
20+
};

0 commit comments

Comments
 (0)