This commit is contained in:
krahets
2023-07-25 16:42:55 +08:00
parent 0760e0865e
commit 902087ec81
23 changed files with 154 additions and 177 deletions
+2 -2
View File
@@ -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)