mirror of
https://github.com/krahets/hello-algo.git
synced 2026-04-13 14:59:53 +08:00
Fix bucket_sort.
This commit is contained in:
@@ -12,7 +12,7 @@ func bucketSort(nums: inout [Double]) {
|
||||
// 1. 将数组元素分配到各个桶中
|
||||
for num in nums {
|
||||
// 输入数据范围 [0, 1),使用 num * k 映射到索引范围 [0, k-1]
|
||||
let i = Int(num) * k
|
||||
let i = Int(num * k)
|
||||
// 将 num 添加进桶 i
|
||||
buckets[i].append(num)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user