This commit is contained in:
krahets
2025-03-20 22:54:57 +08:00
parent e81bc45c43
commit 5286e8bbc2
11 changed files with 79 additions and 78 deletions
@@ -27,9 +27,7 @@ comments: true
"""計數排序"""
# 簡單實現,無法用於排序物件
# 1. 統計陣列最大元素 m
m = 0
for num in nums:
m = max(m, num)
m = max(nums)
# 2. 統計各數字的出現次數
# counter[num] 代表 num 的出現次數
counter = [0] * (m + 1)