Preparing your design workspace

Loading the problem and your saved attempt…

Design and Implement a Hash Map

Design and implement a collision-safe hash map with resizing and a focused public contract.

For this exercise, implement an in-memory hash map for non-null string keys and integer values. Support put, get, containsKey, remove, size, and clear. Put replaces an existing value and returns the previous value when present; get and remove distinguish a missing key explicitly.

Resolve collisions correctly, keep size exact, and resize when the configured load threshold is exceeded. The public behavior must remain correct across negative hash codes, repeated updates, collision-heavy keys, removals, and resize.

Write executable public-contract tests before writing the implementation, show the initially failing tests, and then implement the smallest core that makes them pass. Exclude iteration order, persistence, concurrent mutation, and null keys.