Skip to content

Commit cfdef08

Browse files
authored
Merge pull request neetcode-gh#1719 from AP-Repositories/patch-6
Create 0283-move-zeros.java
2 parents 8d536bd + 99c3c75 commit cfdef08

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

java/283-move-zeros.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Solution {
2+
public void moveZeroes(int[] nums) {
3+
//Do not return anything, modify nums in-place instead.
4+
int l = 0;
5+
for(int r = 0; r < nums.length; r++)
6+
if(nums[r] != 0) {
7+
int tmp = nums[l];
8+
nums[l] = nums[r];
9+
nums[r] = tmp;
10+
l += 1;
11+
}
12+
}
13+
}

0 commit comments

Comments
 (0)