mirror of
https://github.com/krahets/hello-algo.git
synced 2026-07-11 23:16:07 +00:00
build
This commit is contained in:
@@ -141,7 +141,7 @@ $$
|
||||
# 传入 exp 而非 k 可以避免在此重复执行昂贵的次方计算
|
||||
return (num // exp) % 10
|
||||
|
||||
def counting_sort_digit(nums: list[int], exp: int) -> None:
|
||||
def counting_sort_digit(nums: list[int], exp: int):
|
||||
"""计数排序(根据 nums 第 k 位排序)"""
|
||||
# 十进制的位范围为 0~9 ,因此需要长度为 10 的桶
|
||||
counter = [0] * 10
|
||||
@@ -164,7 +164,7 @@ $$
|
||||
for i in range(n):
|
||||
nums[i] = res[i]
|
||||
|
||||
def radix_sort(nums: list[int]) -> None:
|
||||
def radix_sort(nums: list[int]):
|
||||
"""基数排序"""
|
||||
# 获取数组的最大元素,用于判断最大位数
|
||||
m = max(nums)
|
||||
|
||||
Reference in New Issue
Block a user