Problems / Move Zeroes
Easy

Move Zeroes

Easy 0 submissions 10 coins +50 XP
Array Two Pointers
Problem Description
Given an integer array `nums`, move all `0`'s to the end of it while maintaining the relative order of the non-zero elements. Return the modified array after moving all zeroes to the end. **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] Output: [1] ```
Constraints
- `1 <= nums.length <= 10^4` - `-2^31 <= nums[i] <= 2^31 - 1`

Need help?

Connect with expert programmers for real-time collaborative coding, video meetings, and whiteboard sessions via CodeConnect.

Video Call Whiteboard Live Coding Screen Share