diff --git a/codes/go/chapter_sorting/counting_sort.go b/codes/go/chapter_sorting/counting_sort.go index 5d23334a6..a1322347a 100644 --- a/codes/go/chapter_sorting/counting_sort.go +++ b/codes/go/chapter_sorting/counting_sort.go @@ -11,7 +11,7 @@ type CountingSort struct{} func countingSortNaive(nums []int) { // 1. 统计数组最大元素 m m := 0 - for num := range nums { + for _, num := range nums { if num > m { m = num } @@ -36,7 +36,7 @@ func countingSortNaive(nums []int) { func countingSort(nums []int) { // 1. 统计数组最大元素 m m := 0 - for num := range nums { + for _, num := range nums { if num > m { m = num }