mirror of
https://github.com/krahets/hello-algo.git
synced 2026-04-13 12:49:51 +08:00
Add the hashtable based on uthash.h to docs
This commit is contained in:
@@ -30,12 +30,13 @@ void constant(int n) {
|
||||
}
|
||||
|
||||
/* 哈希表 */
|
||||
typedef struct hashTable {
|
||||
struct hashTable {
|
||||
int key;
|
||||
int val;
|
||||
// 借助 LetCode 上常用的哈希表
|
||||
UT_hash_handle hh;
|
||||
} hashTable;
|
||||
UT_hash_handle hh; // 基于 uthash.h 实现
|
||||
};
|
||||
|
||||
typedef struct hashTable hashTable;
|
||||
|
||||
/* 线性阶 */
|
||||
void linear(int n) {
|
||||
@@ -56,7 +57,6 @@ void linear(int n) {
|
||||
|
||||
// 长度为 n 的哈希表占用 O(n) 空间
|
||||
hashTable *h = NULL;
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
hashTable *tmp = malloc(sizeof(hashTable));
|
||||
tmp->key = i;
|
||||
|
||||
Reference in New Issue
Block a user