Move Zeroes

1Easy

Move Zeroes

Given an integer array nums, move all 0s to the end while maintaining the relative order of non-zero elements. Do this in-place.

Example 1:

Input: nums = [0,1,0,3,12] Output: [1,3,12,0,0]

Example 2:

Input: nums = [0] Output: [0]

Example 3:

Input: nums = [1,0,2] Output: [1,2,0]

JR

Jnaneshwara Reddy Satti

Builder · ClearCode

Hi — I'm a 21yo CS grad from India. I built ClearCode while recovering from a surgery, because I genuinely believe DSA should be visual, free, and accessible to everyone. No VC funding. No team. Just me, my laptop, and a lot of chai. ☕

If ClearCode helped you understand even one concept — consider supporting it. Every rupee keeps the servers running and new videos coming.

Support via Razorpay
Support ClearCode ☕
Move Zeroes — Easy Arrays Algorithm | ClearCode