Skip to content

Commit 534036a

Browse files
committed
1
1 parent b9bca22 commit 534036a

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

RemoveElement/RemoveElement.cpp

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
class Solution {
2+
public:
3+
int removeElement(int A[], int n, int elem) {
4+
// Start typing your C/C++ solution below
5+
// DO NOT write int main() function
6+
7+
int low = -1, high;
8+
for (high = 0; high < n; high++) {
9+
if (A[high] != elem) {
10+
low += 1;
11+
A[low] = A[high];
12+
}
13+
}
14+
return low + 1;
15+
}
16+
};

0 commit comments

Comments
 (0)