Skip to main content

Exercise 2: Zero Left

Given an integer array, move all elements equal to 0 to the left side while maintaining the order of other elements in the array. Return an array.

Input: []
Output: []

Input: [1,2,3,0]
Output: [0,1,2,3]

Input: [-1,0,5,3,0]
Output: [0,0,-1,5,3]

Sketch:

Script: