easy
Design HashMap
Implement a hash map for non-negative integer keys without using any built-in map type. Support put(key, value), get(key) returning -1 if absent, and remove(key).
Constraints
- 0 ≤ key, value ≤ 10^6
- At most 10^4 operations
Examples
in: put(1, 1), put(2, 2), get(1), get(3), put(2, 5), get(2), remove(2), get(2)
out: 1, -1, 5, -1
Code it yourself
Solve in
Test execution is not yet available for this exercise.Practice journal →Draft saved in this browser.
Hints:
Which approach applies?
Choose an approach to check your pattern recognition, or reveal the discussion when you need help.