Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements.
Note:
You must do this in-place without making a copy of the array.
Minimize the total number of operations.
給一數字陣列nums,請撰寫一個function將所有的0移到非零數的後面。
注意:你應該要更改原陣列而不是複製一份新的。
盡可能最小化你的步驟。
0
移除,再將0
加回陣列的尾巴直到陣列大小回復。LeetCode
C++