← All sections
Graphs
Generalizes the DFS/BFS already practiced in matrix and tree to the most general structure.
0/6 lessons · exam: 0/30%
Lessons
- ✓01
Recognizing graph problems
Nodes and edges, directed/undirected, representations (adjacency list) and O(V+E).
- ✓02
Pattern 1: DFS and BFS with visited
Traversing a graph without repeating nodes; counting components and cloning a graph.
- ✓03
Pattern 2: Topological sort
Ordering tasks with dependencies and detecting cycles in directed graphs.
- ✓04
Pattern 3: Union-Find (disjoint sets)
Grouping and asking 'are they connected?' in almost O(1) — components and cycles.
- ✓05
Pattern 4: A grid is a graph and multi-source BFS
Treating grids as graphs and propagating waves from several sources at the same time.
- ✓06
Synthesis: which pattern to use?
The Graph section's decision tree and the general quiz before the final exam.
1 easy + 1 medium + 1 hard — unseen problems
With hidden test cases, just like the real LeetCode. This is where you confirm you can leave the section solving any problem of the topic.