Back to DSA sheet
Design HashMap
EasyArraysDesign a hash map without using a built-in map library. Support put(key, value), get(key) returning -1 when absent, and remove(key).
Input format (stdin): the first line has q. Each next line is one of: 'put k v', 'get k', or 'remove k'. For every get operation, print its result on its own line.
Examples
Input: 8
put 1 1
put 2 2
get 1
get 3
put 2 1
get 2
remove 2
get 2
Output: 1
-1
1
-1
get 3 is absent (-1); after remove, get 2 is -1.
Constraints
- 0 <= key, value <= 10^6
- 1 <= q <= 10^4
Sheets
NeetCode 250
design-hashmap.cpp1 sample tests
Loading editor
Test results
Run the sample tests to check your solution against expected output.
Custom input (stdin)
Output
Run your code to see its output.