Given an integer array nums, move all 0's to the end of it while maintaining the relative order of the non-zero elements.
Note that you must do this in-place without making a copy of the array.
How do I solve it
Breakdown:
Create the initial index insert_index.
Go through the nums array and shift all non-zero values to the left.
Once all non-zero values have been shifted, fill the rest of the nums array with zeros.
What is this problem
How do I solve it
Breakdown:
insert_index
.nums
array and shift all non-zero values to the left.nums
array with zeros.