Learn System Design HashMap

Data Structures

HashMap: key → value, instantly

A HashMap stores data as key → value, so you can find a value by its key without checking everything else first. Search the shelves below and watch the shortcut happen.

5 buckets 6 sample keys ~2 min

See it happen

Find a book by its ISBN

Every ISBN runs through isbn % 5 — that number is its shelf. Pick a book and watch the shortcut.

Shelf 0

The Hobbit

Shelf 1

Harry Potter
Lord of the Rings

Shelf 2

Clean Code

Shelf 3

Dune

Shelf 4

1984

Array (linear scan)

HashMap (bucket jump)

The short version

Array vs HashMap, in one scan

In TypeScript, a HashMap is Map<K, V>. "Hashtable" is the older, often-synchronized version of the same idea — TypeScript has no built-in class by that name.

Aspect Array Map (HashMap)
Lookup by key Scan every item — O(n) Jump to the bucket — avg O(1)
TypeScript type Array<T> Map<K, V>
Key types Index only (number) Any value — string, object, etc.
Order Insertion order Insertion order (Map guarantees it)

Test yourself

HashMap basics

Answer from the shelves above. Nothing is saved or sent anywhere.

Question 1 of 3 Score: 0
Two different keys hash to the same bucket. What is this called?

Keep going

More system design breakdowns, built the same way.