Last active
January 15, 2021 01:03
-
-
Save mumunuu/febe527115c0268d3398707a6d2d50c4 to your computer and use it in GitHub Desktop.
algorithm(leetcode) Move Zeroes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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