Push Zeros to end

Given a random integer array, push all the zeros that are present to end of the array. The consecutive order of other elements should remain same.

Change in the input array itself. You don't need to return or print elements.

Input format :

Line 1 : Array Size

Line 2 : Array elements (separated by space)

Sample Input 1:
7
2 0 4 1 3 0 28
Sample Output 1:
2 4 1 3 28 0 0
Sample Input 2:
5
0 3 0 2 0
Sample Output 2:
3 2 0 0 0

Login to submit your solution

Fb dab53a1a64929320dc7425896aa73fd9e5512b6ab52e414ff5f3ebb5cecc73eb

Share Problem