Move zeroes
Problem Move all zeros in an integer array to the end while preserving the relative order of non-zero elements — in place, single pass.
Input / Output
- Input: int array nums. Output: nums mutated in place.
Constraints
- n up to 10^4; O(n) time, O(1) space; minimize writes.
Example
- [0,1,0,3,12] → [1,3,12,0,0].
asked …