Skip to content

Commit

Permalink
Merge pull request neetcode-gh#1719 from AP-Repositories/patch-6
Browse files Browse the repository at this point in the history
Create 0283-move-zeros.java
  • Loading branch information
Ahmad-A0 authored Jan 1, 2023
2 parents 8d536bd + 99c3c75 commit cfdef08
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions java/283-move-zeros.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class Solution {
public void moveZeroes(int[] nums) {
//Do not return anything, modify nums in-place instead.
int l = 0;
for(int r = 0; r < nums.length; r++)
if(nums[r] != 0) {
int tmp = nums[l];
nums[l] = nums[r];
nums[r] = tmp;
l += 1;
}
}
}

0 comments on commit cfdef08

Please sign in to comment.