| Topic | Difficulty | Companies |
|---|---|---|
| Iteration / Two Pointer Approach | EASY | Facebook Uber |
Given an array arr[] of n elements filled with several integers, some of them being zeroes, write a program to move all the zeroes to the end.
Problem Note
Example 1
Input: arr[] = [1, 8, 0, 2, 0, 1, 13, 0]
Output: [1, 8, 2, 1, 13, 0, 0, 0]
Explanation: All the zeroes are moved to the end of array. The order of all other elements is kept same as it is in-place.
Example 2
Input: arr[] = [0, 0, 0, 23, 2]
Output: [23, 2, 0, 0, 0]
Explanation: All the zeroes are moved to the end of array. The order of all the other elements is kept same as it is in-place.