← 返回 linkedin 的题目列表Design a HashMap Class in C++
类型:online_judge
Design and implement a simplified version of a HashMap class using C++. The class should support the following basic functions:
put(key, value): Insert a key-value pair (key, value) into the hash table. If the key already exists, update the corresponding value.
get(key): Return the value associated with the specific key. If the key does not exist, return -1.
remove(key): Delete the data associated with the key in the hash table.
Requirements:
Consider methods for handling collisions, such as using a linked list.
Implement initialization size and dynamic resizing features.
Provide at least three test cases to verify the correctness of your implementation.
Example
Input
put 1 1
put 2 2
get 1
get 3
put 2 1
get 2
remove 2
get 2