标签:图片 function min out move ons must fun 题目
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.
For example, given nums = [0, 1, 0, 3, 12], after calling your function, nums should be [1, 3, 12, 0, 0].
Note:
You must do this in-place without making a copy of the array.
Minimize the total number of operations.
把给定数组中的0全部挪到后边,保持其余数字顺序不变
遍历,把非零元素从前向后赋值给原数组,剩余空位补0。
|
原文:大专栏 【LeetCode】283. Move Zeros
标签:图片 function min out move ons must fun 题目
原文地址:https://www.cnblogs.com/petewell/p/11601691.html