283. Move Zeroes
題目原文
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.
Example:
Note:
You must do this in-place without making a copy of the array.
Minimize the total number of operations.
解題思路
將不是等於0的值往前搬移。
計算補多少0。
程式解答
還沒想到更漂亮的解法
Last updated
Was this helpful?