MCPcopy Create free account
hub / github.com/austingebauer/go-leetcode / moveZeroes

Function moveZeroes

move_zeroes_283/solution.go:7–17  ·  view source on GitHub ↗

Ex: [1,0,0,3,12] i p

(nums []int)

Source from the content-addressed store, hash-verified

5// i
6// p
7func moveZeroes(nums []int) {
8 placement := 0
9 for i := 0; i < len(nums); i++ {
10 if nums[i] != 0 {
11 hold := nums[i]
12 nums[i] = nums[placement]
13 nums[placement] = hold
14 placement++
15 }
16 }
17}
18
19func moveZeroes2(nums []int) {
20 i, j := 0, 1

Callers 1

Test_moveZeroesFunction · 0.85

Calls

no outgoing calls

Tested by 1

Test_moveZeroesFunction · 0.68