Course · Section 9: Data Structures, Modern Operators and Strings · Lecture 124: Maps: Fundamentals
Design a key-value store without using any built-in hash-map library directly in the public API. Implement the `MyHashMap` class: - `put(key, value)` inserts or updates the value for `key`. - `get(key)` returns the value for `key`, or `-1` if it is not present. - `remove(key)` deletes the mapping for `key` if it exists.
+ 1 hidden test run on Submit.
Backing the API with a Map gives O(1) average put/get/remove. get checks presence before returning so absent keys yield -1.
Run your code to see results.