Hash Table
Implement a hash table with the following methods:
- HashTable()constructs a new instance of a hash table
- put(int key, int val)updates the hash table such that- keymaps to- val
- get(int key)returns the value associated with- key. If there is no such- key, then return- -1.
- remove(int key)removes both the- keyand the value associated with it in the hash table.
This should be implemented without using built-in hash table.
Constraints
- n ≤ 100,000where- nis the number of calls to- put,- getand- remove
https://binarysearch.com/problems/Hash-Table
Examples
Example 1
Input
- methods = ['constructor', 'put', 'get', 'remove', 'get']
- arguments = [[], [1, 10], [1], [1], [1]]
Output
- answer = [None, None, 10, None, -1]
 
       
      
Leave a comment