1 | 本题为LeetCode第283道题,为简单题 |
给定一个数组 nums,编写一个函数将所有 0 移动到数组的末尾,同时保持非零元素的相对顺序。
示例:
1 | 输入: [0,1,0,3,12] |
说明:
- 必须在原数组上操作,不能拷贝额外的数组。
- 尽量减少操作次数。
1 | /** |
这道题没啥难度,我就不多说了,再贴上大佬的代码
1 | class Solution { |
秀吧!!!
1 | 本题为LeetCode第283道题,为简单题 |
给定一个数组 nums,编写一个函数将所有 0 移动到数组的末尾,同时保持非零元素的相对顺序。
示例:
1 | 输入: [0,1,0,3,12] |
说明:
1 | /** |
这道题没啥难度,我就不多说了,再贴上大佬的代码
1 | class Solution { |
秀吧!!!