6-10PM challenge problem #001 solution

akbhairwal

akbhairwal

Posted on September 25, 2019

6-10PM challenge problem #001 solution

Problem#001

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
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.

Related

6-10PM challenge problem #002
challenge 6-10PM challenge problem #002

September 25, 2019

6-10PM challenge problem #001 solution
challenge 6-10PM challenge problem #001 solution

September 25, 2019

6-10PM challenge problem #001
challenge 6-10PM challenge problem #001

September 24, 2019