algo/ds-class/shu-zu-lia-39fd9/shu-zu-shu-59850/ #1539
Replies: 1 comment
-
283直接置零解法 class Solution {
public void moveZeroes(int[] nums) {
int n = nums.length;
for (int slow = 0, fast = 0; fast < n; ++fast) {
if (nums[fast] != 0) {
/* No need to overwrite at the same index */
/* Also, nums[fast] = 0 is needed when elements after slow are non-zero */
if (slow != fast) {
nums[slow] = nums[fast];
nums[fast] = 0;
}
slow++;
}
}
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
algo/ds-class/shu-zu-lia-39fd9/shu-zu-shu-59850/
一、快慢指针技巧 二、左右指针的常用算法
https://labuladong.gitee.io/algo/ds-class/shu-zu-lia-39fd9/shu-zu-shu-59850/
Beta Was this translation helpful? Give feedback.
All reactions