Skip to content

Instantly share code, notes, and snippets.

@mumunuu
Last active January 15, 2021 01:03
Show Gist options
  • Save mumunuu/febe527115c0268d3398707a6d2d50c4 to your computer and use it in GitHub Desktop.
Save mumunuu/febe527115c0268d3398707a6d2d50c4 to your computer and use it in GitHub Desktop.
algorithm(leetcode) Move Zeroes
func moveZeroes(nums []int) {
//현재값이 0일 때, 다음 숫자가 0이 아닐때 바꿔준다.
for i := 0; i < len(nums); i++ {
if nums[i] == 0 {
for k := i + 1; k < len(nums); k++ {
if nums[k] != 0 {
nums[i] = nums[k]
nums[k] = 0
break
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment