Easy · Arrays

Move all zeros to end

Given an integer array nums, move every 0 to the end in place so that the non-zero values keep their original relative order; return nothing.

Examples

Example 1

[0,1,0,3,12]

Output: [1,3,12,0,0]

Example 2

[4,0,0,5,0,6]

Output: [4,5,6,0,0,0]

Rebuild it in the studio

Open every published interview problem, solution, scene, and memory room free, with no account.

More Arrays problems