Problem title
Difficulty
Avg time to solve

PAINT THE FENCE
Easy
20 mins
Reverse Words In A String
Easy
10 mins
Wildcard Pattern Matching
Hard
50 mins
Boundary Traversal of Binary Tree
Hard
20 mins
Move Zeroes To End
Moderate
30 mins
Easy
25 mins
Painter's Partition Problem
Moderate
25 mins
Merge Intervals
Moderate
20 mins
Majority element
Easy
15 mins
Sum Of Two Arrays
Easy
15 mins
76

# Move Zeroes To End

Difficulty: MEDIUM
Contributed By
Avg. time to solve
30 min
Success Rate
70%

Problem Statement

#### Input format :

``````The first line of input contains a single integer ‘T’ representing the number of test cases.

The first line of each test case contains a single integer ‘N’ representing the size of the array. The second line of each test case contains ‘N’ integers representing the elements of the array.
``````

#### Output Format :

``````For each test case, modify the input array and print the output in a new line
``````

#### Note :

``````You don’t need to print anything. It has already been taken care of. Just implement the given function.
``````

#### Constraints :

``````1 <= T <= 50
1 <= N <= 10^6
-10000 <= A[i] <= 10000

Where ‘T’ is the number of test cases, ‘N’ is the size of the array, A[i] is the value of the element present at the ith index.
Time Limit:1sec
``````
##### Sample Input 1:
``````2
7
2 0 4 1 3 0 28
5
0 0 0 0 1
``````
##### Sample Output 1:
``````2 4 1 3 28 0 0
1 0 0 0 0
``````
##### The explanation for Sample Output 1 :
``````In the first testcase, All the zeros are moved towards the end of the array, and the non-zero elements are pushed towards the left, maintaining their order with respect to the original array.

In the second testcase, All zero are moved towards the end, hence the only non-zero element i.e 1 is in the starting of the array
``````
##### Sample Input 2:
``````2
5
0 3 0 2 0
4
0 0 0 0
``````
##### Sample Output 2:
``````3 2 0 0 0
0 0 0 0
``````
Console