mirror of
https://github.com/krahets/hello-algo.git
synced 2025-02-02 22:43:50 +08:00
fix:range issue (#496)
This commit is contained in:
parent
a6b3f72826
commit
bae8298c8a
@ -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…
Reference in New Issue
Block a user