C solution
\n#define TBL_SIZE 500\n\nstruct MyListNode {\n\tstruct MyListNode *next;\n\tint val;\n};\n\ntypedef struct {\n\tstruct MyListNode *tbl[TBL_SIZE];\n} MyHashSet;
```\n#define TBL_SIZE 500\n\nstruct MyListNode {\n\tstruct MyListNode *next;\n\tint val;\n};\n\ntypedef struct {\n\tstruct MyListNode *tbl[TBL_SIZE];\n} MyHashSet;\n\n/** Initialize your data structure here. */\n\nMyHashSet* myHashSetCreate() {\n\tMyHashSet *p = (MyHashSet *)malloc(sizeof(MyHashSet));\n\tif (p)\n\t\tmemset(p, 0, sizeof(MyHashSet));\n\treturn p;\n}\n\nvoid myHashSetAdd(MyHashSet* obj, int key) {\n\tint idx = key % TBL_SIZE;\n\tstruct MyListNode **addedNode;\n\tstruct MyListNode *node = obj->tbl[idx];\n\tif (!node) {\n\t\taddedNode = &obj->tbl[idx];\n\t} else {\n\t\twhile (node) {\n\t\t\tif (node->val == key)\n\t\t\t\treturn;\n\t\t\tif (!node->next) {\n\t\t\t\taddedNode = &node->next;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tnode = node->next;\n\t\t}\n\t}\n\t*addedNode = (struct MyListNode *)malloc(sizeof(struct MyListNode));\n\t(*addedNode)->val = key;\n\t(*addedNode)->next = NULL;\n}\n\nvoid myHashSetRemove(MyHashSet* obj, int key) {\n\tint idx = key % TBL_SIZE;\n\tstruct MyListNode *node = obj->tbl[idx];\n\tstruct MyListNode *t;\n\tif (node && node->val == key) {\n\t\tobj->tbl[idx] = node->next;\n\t\tfree(node);\n\t} else {\n\t\twhile (node) {\n\t\t\tif (node->next && node->next->val == key) {\n\t\t\t\tt = node->next;\n\t\t\t\tnode->next = t->next;\n\t\t\t\tfree(t);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tnode = node->next;\n\t\t}\n\t}\n}\n\n/** Returns true if this set contains the specified element */\nbool myHashSetContains(MyHashSet* obj, int key) {\n\tint idx = key % TBL_SIZE;\n\tstruct MyListNode *node = obj->tbl[idx];\n\twhile (node) {\n\t\tif (node->val == key)\n\t\t\treturn true;\n\t\tnode = node->next;\n\t}\n\treturn false;\n}\n\nvoid myHashSetFree(MyHashSet* obj) {\n\tint i;\n\tstruct MyListNode *node, *t;\n\tfor (i = 0; i < TBL_SIZE; i++) {\n\t\tnode = obj->tbl[i];\n\t\twhile (node) {\n\t\t\tt = node->next;\n\t\t\tfree(node);\n\t\t\tnode = t;\n\t\t}\n\t}\n\tfree(obj);\n}\n\n```\n
[]