Data Structures
This plan is about picking the right container for the job. Prefix sums and difference arrays answer range questions without looping, heaps keep the smallest item ready, and union-find tracks which elements belong together.
The 13 chapters open with common enumeration tricks, then work through prefix sums, difference arrays, stacks, queues and deques, heaps, tries, union-find, Fenwick and segment trees, and finish with splay trees, square root decomposition, offline algorithms and other advanced structures. It is the largest plan on Track 1, so take it a chapter at a time.
Want company while you work through this list? Sign in, open the study room, and your heroine will bring you the problems one at a time.
0. Common Enumeration Techniques
§0.1 Enumerate Right, Maintain Left
§0.1.2 Advanced
§0.2 Enumerate Middle
§0.3 Diagonal Traversal
| Problem | Rating |
|---|---|
| 3446. Sort Matrix by Diagonals | 1373 |
| 1329. Sort the Matrix Diagonally | 1548 |
| 498. Diagonal Traverse | 1548 |
I. Prefix Sums
§1.1 Fundamentals
§1.2 Prefix Sums with Hash Tables
§1.3 Distance Sums
§1.4 Bitmask Prefix Sums
§1.5 Advanced Prefix Sums
§1.6 2D Prefix Sums
II. Difference Arrays
§2.1 1D Difference Array
§2.2 2D Difference Array
| Problem | Rating |
|---|---|
| 2536. Increment Submatrices by One | 1583 |
| 850. Rectangle Area II | 2236 |
| 2132. Stamping the Grid | 2364 |
III. Stacks
§3.1 Fundamentals
§3.2 Advanced
§3.3 Adjacent Cancellation
§3.4 Valid Parentheses Strings (RBS)
§3.5 Expression Parsing
§3.6 Two Stacks
| Problem | Rating |
|---|---|
| 2296. Design a Text Editor | 1912 |
IV. Queues & Deques
§4.1 Fundamentals
| Problem | Rating |
|---|---|
| 933. Number of Recent Calls | 1338 |
| 950. Reveal Cards in Increasing Order | 1686 |
| 649. Dota2 Senate | 1686 |
§4.2 Data Structure Design
| Problem | Rating |
|---|---|
| 1670. Design Front Middle Back Queue | 1610 |
| 225. Implement Stack Using Queues | 1851 |
| 232. Implement Queue Using Stacks | 1851 |
| 622. Design Circular Queue | 1851 |
| 641. Design Circular Deque | 1851 |
§4.3 Deque
| Problem | Rating |
|---|---|
| 2810. Faulty Keyboard | 1851 |
§4.4 Monotonic Queue
V. Heaps & Priority Queues
§5.1 Fundamentals
§5.2 Advanced
§5.3 K-th Element
| Problem | Rating |
|---|---|
| 264. Ugly Number II | 1818 |
| 23. Merge K Sorted Lists | 1818 |
§5.4 Rearranging Elements
§5.5 Regret Heap
| Problem | Rating |
|---|---|
| 630. Course Schedule III | 2074 |
| 3362. Zero Array Transformation III | 2424 |
| 2813. Maximum Elegance of a K Length Subsequence | 2582 |
| 3049. Earliest Second to Mark Indices II | 3111 |
§5.6 Lazy Deletion Heap
§5.7 Two Heaps (K-th Smallest/Largest in a Window)
VI. Trie (Prefix Trees)
§6.1 Fundamentals
§6.2 Advanced
§6.3 Trie-Optimized DP
| Problem | Rating |
|---|---|
| 140. Word Break II | 1725 |
§6.4 0-1 Trie (XOR Trie)
| Problem | Rating |
|---|---|
| 1707. Maximum XOR with an Element From Array | 2359 |
| 1938. Maximum Genetic Difference Query | 2503 |
VII. Disjoint Set Union (DSU)
§7.1 Fundamentals
| Problem | Rating |
|---|---|
| 3493. Properties Graph | 1565 |
| 990. Satisfiability of Equality Equations | 1638 |
| 3532. Path Existence Queries in a Graph I | 1725 |
§7.2 Advanced
§7.3 GCD Union-Find
§7.4 Union-Find on Arrays
§7.5 Interval Union-Find
| Problem | Rating |
|---|---|
| 3244. Shortest Distance After Road Addition Queries II | 2270 |
| 1851. Minimum Interval to Include Each Query | 2286 |
§7.6 Weighted Union-Find
| Problem | Rating |
|---|---|
| 399. Evaluate Division | 1725 |
VIII. Fenwick & Segment Trees
§8.1 Fenwick Tree (Binary Indexed Tree)
§8.2 Inversion Pairs
§8.3 Segment Tree (Point Updates)
§8.4 Lazy Segment Tree (Range Updates)
§8.5 Dynamic Segment Tree
| Problem | Rating |
|---|---|
| 699. Falling Squares | 2286 |
| 715. Range Module | 2286 |
| 729. My Calendar I | 2286 |
| 731. My Calendar II | 2286 |
| 732. My Calendar III | 2286 |
| 2276. Count Integers in Intervals | 2222 |
| 3590. Kth Smallest Path XOR Sum | 2646 |
§8.6 Persistent Segment Tree
| Problem | Rating |
|---|---|
| 3762. Minimum Operations to Equalize Subarrays | 2497 |
§8.7 Sparse Table
| Problem | Rating |
|---|---|
| 3501. Maximize Active Section with Trade II | 2941 |
IX. Splay Trees
§9.1 Fundamentals
| Problem | Rating |
|---|---|
| 2296. Design a Text Editor | 1912 |
X. Square Root Decomposition (Mo's)
§8.1 Square Root Decomposition
| Problem | Rating |
|---|---|
| 3655. XOR After Range Multiplication Queries II | 2454 |
§8.2 Mo's Algorithm
| Problem | Rating |
|---|---|
| 3636. Threshold Majority Queries | 2451 |
| 3590. Kth Smallest Path XOR Sum | 2646 |
§8.3 Miscellaneous
| Problem | Rating |
|---|---|
| 3234. Count the Number of Substrings with Dominant Ones | 2557 |
XI. Offline Algorithms
§10.1 Fundamentals
XII. Advanced Data Structures
Part A
| Problem | Rating |
|---|---|
| 2532. Time to Cross a Bridge | 2589 |
| 2056. Number of Valid Move Combinations on Chessboard | 2611 |
Part B
If you set a rating ceiling of 1600 or 1900, harder problems here wait in your challenge list, and your heroine asks before raising the limit.
Ratings come from zerotrac's LeetCode contest ratings. Some problems have no zerotrac rating and are marked Unrated.
Open the study room