Skip to content

Commit c946cef

Browse files
committed
Add Arrays/27_Remove_Element.java
1 parent 5529434 commit c946cef

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Arrays/27_Remove_Element.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
class Solution {
2+
public int removeElement(int[] nums, int val) {
3+
int i = 0, j = 0;
4+
5+
while (i < nums.length) {
6+
if (nums[i] != val) {
7+
nums[j] = nums[i];
8+
++j;
9+
}
10+
11+
++i;
12+
}
13+
14+
return j;
15+
}
16+
}

0 commit comments

Comments
 (0)