Given an integer array nums, move all 0s to the end while maintaining the relative order of non-zero elements. Do this in-place.
Input: nums = [0,1,0,3,12] Output: [1,3,12,0,0]
Input: nums = [0] Output: [0]
Input: nums = [1,0,2] Output: [1,2,0]
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.