Tags

Hash Map / Dictionary

Hash Map / Dictionary

4 lessons
36 problems
2 code snippets
9 question banks
7 community items

hash-map

Data Structures

3 lessons

Hash Map (Dictionary) Basics

Free
Beginner

50 min

1 prereq

Two Sum is the canonical example: scan the array once, and for every number `x` ask the data structure whether you have already seen `target - x`. With a list that is `O(n^2)`. With a **Hash Map**, the lookup becomes a single function call and the whole algorithm collapses to `O(n)`. This lesson covers the key-value abstraction, the intuition behind a hash function (a key gets converted to a bucket index by an integer-valued function), what a collision is, and how `get`, `set`, `delete`, and `has` behave in JavaScript's `Map` and Python's `dict`. You will also meet two recurring patterns: counting frequencies and bucketing/grouping by a derived key, both of which appear in dozens of interview problems and real applications such as analytics, caching, and indexing. In **Arrays & Strings**, you saw that searching an unsorted array is `O(n)` because every position is equally plausible. A hash map turns that linear scan into an arithmetic computation that points directly at the right slot, which is the entire reason hash-based lookups dominate practical software. With key-based lookup in hand, **Set Basics** specializes the same machinery to a single question: have I seen this value before?

Not Started

0%

Hash Map / Dictionary
Hashing
Hash Functions
Collisions
Data Structures
Beginner
Free
Time Complexity

LRU Cache (Hash Map + DLL)

Intermediate

55 min

2 prereqs

Hold a fixed number of recently used items, evict the least-recently-touched one when you run out of room, and answer both `get(key)` and `put(key, value)` in `O(1)`. No single primitive does that: a hash map gives `O(1)` lookup but no recency order, and a doubly linked list gives `O(1)` recency moves but no key index. The classical **LRU Cache** wires the two together so each compensates for what the other lacks. This lesson designs the composite from scratch: a hash map that points keys to DLL nodes, and a doubly linked list that orders nodes by recency with most-recent at the head and least-recent at the tail. You will trace `get` and `put` through both structures, handle the capacity-of-one and update-existing-key edge cases, and see why this design appears in browser caches, database query caches, OS page replacement, and CDNs. In **Hash Map (Dictionary) Basics**, you used a hash map for `O(1)` lookup by key. **Doubly Linked List** added the `prev` pointer that makes mid-list deletion `O(1)` once you hold the node, plus the sentinel pattern that erases null checks at the boundaries; both are load-bearing here. The LRU pattern (one structure for indexing, another for ordering, kept consistent on every operation) is the gateway to a wider family of composite designs covered in later lessons.

Not Started

0%

LRU Cache
Hash Map / Dictionary
Doubly Linked List
Data Structures
Intermediate
Premium
Interview Prep
Time Complexity

Trie (Prefix Tree)

Intermediate

55 min

2 prereqs

Type the letters `a-p-p` into a search box and the autocomplete dropdown produces `apple`, `application`, `apply`, and `appoint` before you finish the next keystroke. The data structure doing that work is a **Trie** (or prefix tree), where every stored word is a path from root to a marked node and every shared prefix is shared in memory exactly once. This lesson covers the trie node layout (a `children` map plus an `isEndOfWord` flag), `insert`, `search`, and `startsWith` operations that all run in `O(m)` for a query of length `m` (independent of how many words the trie holds), and a `delete` that has to be careful not to break paths used by other words. You will also analyze the space behavior, including when a trie wins over a hash set (prefix queries, lexicographic enumeration) and when it loses (memory-tight workloads with no prefix structure to exploit). In **Hash Map (Dictionary) Basics**, you used hashing to answer 'have I seen this exact key' in `O(1)`; a trie answers a strictly richer question (any prefix lookup) by trading `O(1)` exact-match for `O(m)` traversal. **Trees: Binary Tree Fundamentals** introduced the recursive child-pointer pattern, and a trie generalizes it from two children per node to one child per alphabet symbol. With a trie in your toolkit, the curriculum moves on to graph and hash extensions that solve a different family of problems built on the same node-and-edge thinking.

Not Started

0%

Trie / Prefix Tree
Trie Operations
Trees
Data Structures
Strings
Searching
Hash Map / Dictionary
Intermediate
Premium

Algorithms

1 lesson

Hashing Techniques

Free
Beginner

45 min

1 prereq

Two Sum was a hard problem in 2010. With a hash map it becomes a six-line interview warm-up: walk the array once, and for each value `x` ask whether `target - x` is already in the map. The same shape, single-pass plus complement lookup, solves "first duplicate," "contains nearby duplicate," "longest substring without repeats," and an entire family of trade-space-for-time problems. **Hashing Techniques** catalogs those patterns. You will work through frequency counting (most/least frequent element, group anagrams via sorted-key trick), the two-sum complement template and its three-sum / four-sum extensions, existence checking and duplicate detection, index mapping where you store positions alongside values, and a first conceptual look at rolling hashes that prepare you for Rabin-Karp later. The lesson also discusses when a hash map is overkill versus when it is the obviously correct tool. In **Hash Map (Dictionary) Basics**, you saw how hashing achieves expected `O(1)` insertion and lookup. This lesson is where that constant-time primitive turns into algorithmic leverage: brute-force `O(n^2)` scans collapse into a single pass that uses the map as an oracle. From here you move into the paid track with **Sorting (Advanced)**, which trades hash-map lookups for divide-and-conquer to break the `O(n^2)` sorting barrier.

Not Started

0%

Algorithms
Hashing
Hash Map / Dictionary
Searching
Patterns
Problem Solving
Beginner
Free

Practice Problems

36 problems

Contains Duplicate II

Free
Not Started
Easy

Check if an array contains two distinct indices with the same value whose absolute difference is at most k.

Arrays
Hash Map / Dictionary
Sliding Window
Beginner

181

1

Happy Number

Free
Not Started
Easy

Determine if a number is happy by repeatedly replacing it with the sum of the squares of its digits until it reaches 1 or enters a cycle.

Mathematics
Hash Map / Dictionary
Fast/Slow Pointers
Cycle Detection
Beginner

1k

4

Isomorphic Strings

Free
Not Started
Easy

Determine if two strings are isomorphic, where each character in one string can be mapped to exactly one character in the other.

Arrays
Hash Map / Dictionary
Strings
Beginner

1.1k

21

Majority Element

Free
Not Started
Easy

Given an array, find the element that appears more than half the time using Boyer-Moore Voting.

Arrays
Hash Map / Dictionary
Beginner

350

4

Next Greater Element I

Free
Not Started
Easy

Given two arrays where nums1 is a subset of nums2, find the next greater element in nums2 for each element in nums1.

Stack
Monotonic Stack
Hash Map / Dictionary
Beginner

896

27

Ransom Note

Free
Not Started
Easy

Determine if a ransom note can be constructed from the characters available in a magazine string.

Arrays
Hash Map / Dictionary
Strings
Beginner

1.1k

31

Two Sum

Free
Not Started
Easy

Given an array of integers and a target, return the indices of the two numbers that add up to the target.

Arrays
Hash Map / Dictionary
Beginner

657

21

Valid Anagram

Free
Not Started
Easy

Given two strings, determine if one is an anagram of the other by comparing character frequencies.

Arrays
Hash Map / Dictionary
Strings
Beginner

1k

27

Word Pattern

Free
Not Started
Easy

Check if a string of words follows the same pattern as a given pattern string, using a bijective character-to-word mapping.

Arrays
Hash Map / Dictionary
Strings
Beginner

240

4

Max Points on a Line

Not Started
Hard

Given an array of points on a 2D plane, find the maximum number of points that lie on the same straight line.

Mathematics
Hash Map / Dictionary
Computational Geometry
Algorithms
Advanced
Number Theory
GCD / LCM

873

27

Minimum Window Substring

Not Started
Hard

Find the smallest substring of s that contains all characters of t, including duplicates.

Strings
Sliding Window
Hash Map / Dictionary
Frequency Count
Advanced

346

9

Substring with Concatenation of All Words

Not Started
Hard

Find all starting indices where a concatenation of all given words (each of equal length) forms a substring.

Strings
Sliding Window
Hash Map / Dictionary
Frequency Count
Advanced

455

14

Accounts Merge

Not Started
Medium

Given a list of accounts where each account has a name and emails, merge accounts that share a common email address.

Graphs
Union-Find / DSU
DFS
Hash Map / Dictionary
Intermediate

155

5

Clone Graph

Free
Not Started
Medium

Given a reference to a node in a connected undirected graph, return a deep copy (clone) of the entire graph.

Graphs
DFS
BFS
Hash Map / Dictionary
Clone Graph
Intermediate

1k

19

Copy List with Random Pointer

Free
Not Started
Medium

Create a deep copy of a linked list where each node has a next pointer and a random pointer that can point to any node in the list or null.

Singly Linked List
Hash Map / Dictionary
Intermediate

708

7

Design Twitter

Free
Not Started
Medium

Design a simplified Twitter with post, follow/unfollow, and a news feed that merges recent tweets from followed users using a heap.

Heap
Min Heap
Priority Queue
Hash Map / Dictionary
Data Structures
Intermediate

638

11

Detect Squares

Not Started
Medium

Design a data structure that supports adding points on a 2D plane and counting the number of ways to form axis-aligned squares with a given query point as one corner.

Mathematics
Hash Map / Dictionary
Computational Geometry
Algorithms
Intermediate

417

13

Evaluate Division

Not Started
Medium

Given equations like a/b = k, answer queries asking for the result of x/y using graph traversal on a weighted directed graph.

Graphs
DFS
BFS
Weighted Graphs
Hash Map / Dictionary
Intermediate

537

12

Find All Anagrams in a String

Not Started
Medium

Find all start indices where an anagram of pattern p occurs in string s.

Strings
Sliding Window
Hash Map / Dictionary
Frequency Count
Anagrams
Intermediate

1.1k

22

Group Anagrams

Free
Not Started
Medium

Group an array of strings so that anagrams appear together, using a hash map with sorted-character keys.

Arrays
Strings
Hash Map / Dictionary
Sorting
Anagrams
Intermediate

566

11

Hand of Straights

Not Started
Medium

Given an array of integers and a group size, determine if the array can be rearranged into groups where each group consists of consecutive integers of the given size.

Greedy
Hash Map / Dictionary
Sorting
Arrays
Algorithms
Intermediate

405

2

Insert Delete GetRandom O(1)

Not Started
Medium

Design a data structure that supports insert, remove, and getRandom in average O(1) time using a hash map paired with a dynamic array.

Arrays
Hash Map / Dictionary
Randomized Algorithms
Intermediate

889

4

Integer to Roman

Not Started
Medium

Convert an integer to its Roman numeral representation using a greedy approach with a value-symbol mapping.

Strings
Hash Map / Dictionary
Greedy
Intermediate

572

16

Longest Consecutive Sequence

Free
Not Started
Medium

Find the length of the longest consecutive element sequence in an unsorted array in O(n) time using a hash set.

Arrays
Hash Map / Dictionary
Set
Intermediate

1k

24

Longest Repeating Character Replacement

Free
Not Started
Medium

Find the length of the longest substring containing the same letter after performing at most k character replacements.

Strings
Sliding Window
Hash Map / Dictionary
Intermediate

212

5

Longest Substring Without Repeating Characters

Free
Not Started
Medium

Find the length of the longest substring without repeating characters using the sliding window technique.

Strings
Sliding Window
Hash Map / Dictionary
Intermediate

506

3

LRU Cache

Free
Not Started
Medium

Design a data structure that follows the Least Recently Used (LRU) cache constraints, supporting get and put operations in O(1) time.

Singly Linked List
Doubly Linked List
Hash Map / Dictionary
LRU Cache
Intermediate

761

9

Partition Labels

Not Started
Medium

Given a string, partition it into as many parts as possible so that each letter appears in at most one part, and return a list of the sizes of these parts.

Greedy
Strings
Hash Map / Dictionary
Algorithms
Intermediate

850

18

Permutation in String

Not Started
Medium

Given two strings, determine if one string's permutation is a substring of the other.

Strings
Sliding Window
Hash Map / Dictionary
Frequency Count
Intermediate

1.1k

37

Roman to Integer

Not Started
Medium

Convert a Roman numeral string to an integer by mapping symbols to values and handling subtractive notation.

Strings
Hash Map / Dictionary
Intermediate

917

18

Set Matrix Zeroes

Free
Not Started
Medium

Given an m x n integer matrix, if an element is 0, set its entire row and column to 0 using constant extra space.

Arrays
Matrix Algorithms
Matrix Traversal
In-Place
Hash Map / Dictionary
Intermediate

861

14

Subarray Sum Equals K

Not Started
Medium

Count the total number of contiguous subarrays whose sum equals k using a prefix sum hash map technique.

Arrays
Hash Map / Dictionary
Prefix Sum
Subarray / Substring Problems
Intermediate

708

22

Time Based Key-Value Store

Not Started
Medium

Design a key-value store that can store multiple values for the same key at different timestamps and retrieve the value at a given timestamp using binary search.

Binary Search
Hash Map / Dictionary
Searching
Intermediate

567

17

Top K Frequent Elements

Free
Not Started
Medium

Find the k most frequent elements in an array using a hash map for counting and bucket sort for efficient selection.

Arrays
Hash Map / Dictionary
Sorting
Bucket Sort
Top-K Elements
Intermediate

1.1k

12

Valid Sudoku

Not Started
Medium

Determine if a 9x9 Sudoku board is valid by checking rows, columns, and 3x3 sub-boxes for duplicate digits using hash sets.

Arrays
Hash Map / Dictionary
Set
Matrix Algorithms
Intermediate

1k

24

Word Break

Free
Not Started
Medium

Given a string and a dictionary of words, determine if the string can be segmented into a space-separated sequence of dictionary words.

Dynamic Programming
Tabulation
Hash Map / Dictionary
Set
Strings
Algorithms
Intermediate

977

24

Question Banks

9 items
Question Bank

Array Cross-Reference and Lookup Challenges

Six lookup-and-filter drills: id-to-id matching with Sets, random sampling without duplicates, valid-only filtering, numeric-only extraction, value-by-row matching, and rest-parameter multipliers.

JavaScript
quiz
arrays
hash-map
array-manipulation-patterns

1k

27

Medium
Question Bank
Premium

Array Sorting and Grouping Challenges

Six sorting/grouping problems: dynamic key sort, multi-key sort, top-N average, date sort, top-N max preserving identity, group-by, and id-driven custom ordering.

JavaScript
quiz
arrays
sorting
hash-map

361

9

Hard
Question Bank

JavaScript Group Students by ID: Two Approaches Quiz

Two seeded approaches to group an array of student records by id (reduce + dict and the `in` operator), plus two companions on Map and Object.groupBy.

JavaScript
quiz
arrays
hash-map
array-manipulation-patterns

419

8

Medium
Question Bank
Premium

JavaScript Character Occurrence Count: Three Approaches Quiz

Count how often each unique character from a needle string appears in a haystack, three ways (Set + per-char count, dict tally, regex match per char), plus two companions on case folding and a single-pass tally.

JavaScript
quiz
strings
hash-map
interview-prep

690

2

Hard
Question Bank

JavaScript Array Occurrences Count: Two Approaches Quiz

Tally how many times each value appears in an array, two ways (reduce + dict and Map-based counter), plus two companions on Object.create(null) safety and case-insensitive string tallies.

JavaScript
quiz
arrays
hash-map
array-manipulation-patterns

886

27

Medium
Question Bank
Premium

JavaScript String Duplicate Finder: Two Approaches Quiz

Tally character frequencies in a string two ways (explicit loop + counter dict and reduce one-liner), plus two companions on Unicode-aware iteration and duplicates-only filtering.

JavaScript
quiz
strings
hash-map
interview-prep

583

6

Hard
Question Bank
Premium

JavaScript Grouped Scores Filter: Two Approaches Quiz

Filter a grouped scores object so each row keeps only requested keys, solved two ways (Object.entries + map and a for-in loop), plus companions on Map output and key-rename mapping.

JavaScript
quiz
arrays
hash-map
array-manipulation-patterns

281

6

Hard
Question Bank

JavaScript Pair-Sum Finder: Two Approaches Quiz

Two seeded ways to test whether two numbers in an array add up to a target (nested loop and Set complement), plus two companions on time complexity and on returning the actual pair instead of a boolean.

JavaScript
quiz
arrays
hash-map
interview-prep

1.1k

35

Medium
Question Bank
Premium

JavaScript Group By ID with Average Score: Two Approaches Quiz

Two seeded ways to group records by id and compute each group's average (bucket-then-divide vs running sum + count), plus two companions on min/max per group and on memory trade-offs at scale.

JavaScript
quiz
arrays
hash-map
array-manipulation-patterns

329

5

Hard

Community

7 items
Problem
Medium
Free

Design HashMap

Implement a HashMap from scratch using a fixed bucket array with separate chaining; support put / get / remove on integer keys.

hash-map
hash-table
linked-list

312

2

4.3 (9)

May 11, 2026

by @chloekelly

Article

Hash Tables: The Most Useful Data Structure

Why hash tables earn their reputation, where collisions and load factor actually bite, and the language-specific quirks (JS Map vs Object, Python dict, Java HashMap) that change the game.

hash-table
hash-map
data-structures
fundamentals
interview-prep

607

14

4.4 (13)

Apr 16, 2026

by @oliviafoster

Code Snippet

Dedupe by Key With Last-Write-Wins (JS)

dedupeBy(rows, 'id') is the function I copy into every ETL script. Last-write-wins is the right policy 90% of the time; this version also exposes a configurable resolver for the other 10%.

JavaScript
hash-map
code-template
data-pipeline

561

5

4.7 (8)

Apr 15, 2026

by @camilarao

Question Bundle
Free

Core Data Structures Warmup

Two quick whiteboard questions on array vs linked list complexity and hash-map two-sum. Five minutes each.

JavaScript
fundamentals
arrays
hash-map
warmup

1k

24

3.5 (25)

Apr 11, 2026

by @ezb1981

Problem
Medium
$10.00

Top K Frequent Elements

Return the k most frequent elements in O(n) time using bucket sort by frequency. A staple of mid-level interview rotations.

hash-map
bucket-sort
heap
interview-prep

996

23

3.8 (41)

Mar 24, 2026

by @ezb1981

Problem
Easy
Free

Valid Anagram

Decide whether two strings are anagrams of each other in O(n) using a frequency map.

strings
hash-map
fundamentals

381

7

3.8 (11)

Mar 22, 2026

by @ezb1981

Article

LRU Cache From Scratch in 50 Lines

A working LRU cache built from a hash map plus a doubly linked list, the part interview answers leave out (concurrency, eviction callbacks, byte budgets), and when LRU is the wrong eviction policy.

lru-cache
doubly-linked-list
hash-map
cache-invalidation
data-structures

346

1

4.3 (14)

Jan 30, 2026

by @vikramokoro