Move Zeroes

Given an array nums, move all 0's to the end while maintaining the relative order of non-zero elements.

Input Format

nums = array of integers

Output Format

modified array with zeroes moved to end

Constraints

  • 1 <= nums.length <= 10^5; -10^9 <= nums[i] <= 10^9

Examples

Example 1:

Input:

nums = [0,1,0,3,12]

Output:

[1,3,12,0,0]

Explanation:

Non-zero elements moved front, zeros at end.

Loading...
Move Zeroes - Arrays DSA Problem