Foundations
Linear Structures
Hashing
Array and String Patterns
Recursion, Search, and Sorting
Problem Solving Patterns
Algorithm Searching
Sorting Algorithms
Array Algorithms
Grid Algorithms
Linear Structure Algorithms
Hashing Algorithms
Recursion and Backtracking
Greedy Algorithms
Tree and Heap Algorithms
Graph Algorithms
Dynamic Programming Algorithms
String Algorithms
Math Algorithms
Keyboard ready
Space plays. Arrow keys step. R restarts.
LAB Hash Maps Lab
Hashing
Concept shape
Core
key
bucket 0
bucket 1
bucket 2
bucket 3
Definition
A hash map stores key-value pairs and gives fast average lookup by key.
Step 1 / 5
Concept shape
Hashing Core
Hash Maps
Welcome to the Hash Maps concept lab. A hash map stores key-value pairs and gives fast average lookup by key. The must know points are: Average lookup is O(1). Keys must be hashable. Great for frequency and lookup problems. The common operations are: get average O(1), set average O(1), delete average O(1), contains average O(1). The complexity shape is Average O(1), worst O(n). Watch out for these pitfalls: Assuming iteration order unless guaranteed. Forgetting collision worst cases. Using mutable objects as keys incorrectly. Related algorithms include Two Sum, Prefix Sum with Hash Map.
Concept details
A hash map stores key-value pairs and gives fast average lookup by key.
Must know
- Average lookup is O(1).
- Keys must be hashable.
- Great for frequency and lookup problems.
Complexity
Average O(1), worst O(n)
1.0x