Move Zeroes to End
00:00
AccentureTCS
Move all zeros to the end of the array while maintaining relative order of non-zero elements. Modify in-place with O(1) extra memory.
Examples
Input → [0,1,0,3,12]
Output → [1,3,12,0,0]
Input → [0]
Output → [0]
Input → [0,0,1]
Output → [1,0,0]
Input → [1,2,3]
Output → [1,2,3]
Note: no change