6-10PM challenge problem #001 solution
akbhairwal
Posted on September 25, 2019
Move Zeros To End
public int[] moveZerosToEnd(int[] arr) {
int j = 0;
for (int i = 0; i < arr.length; i++) {
if (arr[i] != 0) {
arr[j] = arr[i];
j++;
}
}
for (; j < arr.length; j++) {
arr[j] = 0;
}
return arr;
}
💖 💪 🙅 🚩
akbhairwal
Posted on September 25, 2019
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.