Fix some code bugs (#1021)

* fix(counting_sort.c): Fix access out-of-bounds issue

* fix(hash_map_open_addressing.c): Fix coding errors

* fix(binary_search_tree.c): Fix unreleased memory

* Update indentataion
This commit is contained in:
gonglja
2024-01-02 21:45:01 +08:00
committed by GitHub
parent ef40418129
commit 3a559f1b60
3 changed files with 5 additions and 3 deletions
+1 -1
View File
@@ -18,7 +18,7 @@ void countingSortNaive(int nums[], int size) {
}
// 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]]++;
}