mirror of
https://github.com/halfrost/LeetCode-Go.git
synced 2025-07-05 16:36:41 +08:00
17 lines
219 B
Go
17 lines
219 B
Go
package leetcode
|
|
|
|
func moveZeroes(nums []int) {
|
|
if len(nums) == 0 {
|
|
return
|
|
}
|
|
j := 0
|
|
for i := 0; i < len(nums); i++ {
|
|
if nums[i] != 0 {
|
|
if i != j {
|
|
nums[i], nums[j] = nums[j], nums[i]
|
|
}
|
|
j++
|
|
}
|
|
}
|
|
}
|