@@ -0,0 +1,1073 @@
+package array;%0A%0Aimport java.util.Arrays;%0A%0A/**%0A * http://www.geeksforgeeks.org/move-zeroes-end-array/%0A * Given an array of random numbers, Push all the zero%E2%80%99s of a given array to the end of the array.%0A * For example, if the given arrays is %7B1, 9, 8, 4, 0, 0, 2, 7, 0, 6, 0%7D, it should be changed to %7B1, 9, 8, 4, 2, 7, 6, 0, 0, 0, 0%7D.%0A * The order of all other elements should be same. Expected time complexity is O(n) and extra space is O(1)%0A */%0Apublic class MoveAllZeroesToEndOfArray %7B%0A    public void pushZerosToEnd(int arr%5B%5D) %7B%0A        int length = arr == null ? 0 : arr.length;%0A        if (length == 0) return;%0A        int index = 0;%0A        for (int i = 0; i %3C length; i++) %7B%0A            if (arr%5Bi%5D != 0) %7B%0A                arr%5Bindex++%5D = arr%5Bi%5D;%0A            %7D%0A        %7D%0A        while (index %3C length) %7B%0A            arr%5Bindex++%5D = 0;%0A        %7D%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        int%5B%5D arr = %7B1, 9, 8, 4, 0, 0, 2, 7, 0, 6, 0%7D;%0A        new MoveAllZeroesToEndOfArray().pushZerosToEnd(arr);%0A        System.out.println(Arrays.toString(arr));%0A    %7D%0A%7D%0A

move zeroes end array