fix:range issue (#496)

pull/498/head
ZeYanLin 2 years ago committed by GitHub
parent a6b3f72826
commit bae8298c8a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -11,7 +11,7 @@ type CountingSort struct{}
func countingSortNaive(nums []int) { func countingSortNaive(nums []int) {
// 1. 统计数组最大元素 m // 1. 统计数组最大元素 m
m := 0 m := 0
for num := range nums { for _, num := range nums {
if num > m { if num > m {
m = num m = num
} }
@ -36,7 +36,7 @@ func countingSortNaive(nums []int) {
func countingSort(nums []int) { func countingSort(nums []int) {
// 1. 统计数组最大元素 m // 1. 统计数组最大元素 m
m := 0 m := 0
for num := range nums { for _, num := range nums {
if num > m { if num > m {
m = num m = num
} }

Loading…
Cancel
Save