Given an array A of positive integers. Push all the zero’s of the given array to the end of the array. while maitaining the order of non-zero elements.
The first line contains an integer T denoting the total number of test cases. In each test cases, first line is number of elements in array N and next line contains array elements.
For each testcase, in a new line, print the array after shifting all 0's to the end.
1 <= T <= 100
1 <= N <= 103
0 <= Ai <=103
3 5 0 0 4
0 0 0 4
3 5 4 0 0
4 0 0 0
Testcase 1: The non-zero elements are preserve their order while the 0 elements are moved to the right.
Testcase 1: 4 is the only non-zero element and it gets moved to the left.
If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.