Move Zeroes Problem
Move Zeroes Problem — ExecCode Easy DSA Practice
Solve the Move Zeroes problem on ExecCode. Free online easy DSA practice in Arrays - Logic Building. Write and run code in Java, C++, Python — no signup required to run.
Problem description
Move all zeroes to the end of nums in place while keeping the relative order of non-zero values. Use read to scan the array and write to mark the next non-zero slot.
Examples
Input nums = [0,1,0,3,12]; Output [1,3,12,0,0]. Input nums = [0,0,1]; Output [1,0,0]
Constraints
1 ≤ nums.length ≤ 10⁴ -2³¹ ≤ nums[i] ≤ 2³¹ - 1
Practice Move Zeroes free on ExecCode. Browse DSA problems, topic map, and placement guides.