This commit is contained in:
krahets
2024-01-03 17:56:11 +08:00
parent ac953ef830
commit fc3c3c6400
4 changed files with 6 additions and 4 deletions
+1 -1
View File
@@ -299,7 +299,7 @@ comments: true
}
// 2. 统计各数字的出现次数
// counter[num] 代表 num 的出现次数
int *counter = calloc(m, sizeof(int));
int *counter = calloc(m + 1, sizeof(int));
for (int i = 0; i < size; i++) {
counter[nums[i]]++;
}