← 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

  1. ✓01

    Recognizing graph problems

    Nodes and edges, directed/undirected, representations (adjacency list) and O(V+E).

  2. ✓02

    Pattern 1: DFS and BFS with visited

    Traversing a graph without repeating nodes; counting components and cloning a graph.

  3. ✓03

    Pattern 2: Topological sort

    Ordering tasks with dependencies and detecting cycles in directed graphs.

  4. ✓04

    Pattern 3: Union-Find (disjoint sets)

    Grouping and asking 'are they connected?' in almost O(1) — components and cycles.

  5. ✓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.

  6. ✓06

    Synthesis: which pattern to use?

    The Graph section's decision tree and the general quiz before the final exam.

🏁 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.