LeetCode by Example

Welcome to the LeetCode by Example course! This course was originally serialized on WeChat Official Account in 2020 and received widespread acclaim.

Through carefully selected example problems, this course will help you:

  1. Master techniques for working with classic data structures like linked lists and binary trees
  2. Learn common algorithmic thinking patterns such as recursion and traversal
  3. Improve your ability to solve algorithm problems

Each chapter walks through specific example problems, explaining the thought process, solutions, and related concepts in detail. At the end of each chapter, similar practice problems are provided to help you reinforce what you’ve learned.

Let’s begin our algorithm learning journey!

Course Chapters

1

Reverse Linked List: How to Easily Restructure a Linked List

2

Path Sum: Subproblem Decomposition in Binary Trees

3

From Binary Tree Traversal to Backtracking

4

Solving Two Sum with Two Pointers: Reducing the Search Space

Exercise

Container With Most Water (Reservoir Problem)

5

Two Pointers × Linked List Problems: Fast and Slow Pointers

Exercise

Linked List Comprehensive Problem: Sorting a Linked List

6

The Power of Basic Operations: Reverse as an Example

7

The Anagram Problem: The Power of Basic Data Structures

8

Permutation and Combination: Candidate Sets in Backtracking

9

Revisiting Permutations and Combinations: Deduplication Strategies in Backtracking

Exercise

Solving the Combination Sum Series with One Template

10

Diameter of Binary Tree: Global Variables in Binary Tree Traversal

11

Converting a Binary Tree to a Linked List: Operating on Adjacent Nodes in Binary Tree Inorder Traversal

Exercise

Binary Tree Problems Too Complex? A Three-Step Method to Solve Them!

12

Island Problems: DFS on Grid Structures

13

Use Cases for BFS: Level-Order Traversal and Shortest Path Problems

14

House Robber: Four Steps to Solving Dynamic Programming Problems

15

Longest Common Subsequence: Solving with Two-Dimensional Dynamic Programming

Exercise

Classic Dynamic Programming: Edit Distance

16

Maximum Subarray Sum: Dynamic Programming Techniques for Subarray Problems

17

Splitting Subproblems in Dynamic Programming to Simplify Your Approach

Exercise

A Practical yet Elegant Approach to Stock Trading Problems

18

Prefix Sum: A Space-for-Time Technique

Exercise Chapters