This repository contains 60+ original articles based on LeetCode problems, covering all problem types and techniques. The goal is to help you think algorithmically — not just memorize solutions.
When it comes to LeetCode, what matters is not the answer itself, but the thought process behind it. A repository full of raw code without explanation isn't very useful. The real value lies in understanding the frameworks and patterns that let you solve new problems on your own.
Most people grind LeetCode to land a job, not to compete in programming contests. So the focus here is on clarity and practical understanding — building reusable mental frameworks that make algorithm problems approachable and solvable.
1. Give this repo a star if you find it helpful — it keeps me motivated to write more.
2. I recommend studying on my website, where each article links to the corresponding LeetCode problems so you can read and practice side by side. The site covers 500+ problems with step-by-step guidance:
https://labuladong.online/en/algo/
-
Getting Started: Data Structures and Sorting
-
Implement and Visualize 10 Sorting Algorithms
- Chapter Introduction
- Key Metrics of Sorting Algorithms
- Explore Selection Sort in Depth
- Bubble Sort with Stability
- Insertion Sort with Reverse Thinking
- Shell Sort - Better than O(N^2)
- Quick Sort and Binary Tree Preorder
- Merge Sort and Binary Tree Postorder
- Heap Sort and Binary Heap
- Counting Sort: A New Pespective on Sorting
- Bucket Sort
- Radix Sort
-
Chapter 0. Classic Problem Solving Templates
- Chapter Introduction
- How to Think About Data Structure and Algorithm
- Two Pointer Techniques for Linked List Problems
- Two Pointer Techniques for Array Problems
- Sliding Window Algorithm Code Template
- Thinking Recursion Algorithms from Binary Tree Perspective
- One Perspective + Two Thinking Patterns to Master Recursion
- Dynamic Programming Common Patterns and Code Template
- Backtracking Algorithm Common Patterns and Code Template
- BFS Algorithm Common Patterns and Code Template
- Backtracking Algorithm to Solve All Permutation/Combination/Subset Problems
- Greedy Algorithms Principles and Techniques
- Divide and Conquer Principles and Techniques
- Time and Space Complexity Analysis Practical Guide
-
Chapter 1. Data Structure Algorithms
-
- Two Pointer Techniques for Array Problems
- Match Three Game
- Tricks to Traverse a 2D Array
- Exercise: Two Pointer Techniques for Array
- Game of Life
- One Trick to Solve All N-Sum Problems
- Prefix Sum Array Technique
- Exercise: Prefix Sum Techniques
- Difference Array Technique
- Sliding Window Algorithm Code Template
- Exercise: Sliding Window In Action
- Sliding Window: Rabin Karp Algorithm
- Binary Search Algorithm Code Template
- Binary Search Follow-up
- Binary Search in Action
- Exercise: Binary Search Algorithm
- Weighted Random Selection Algorithm
- Advantage Shuffle Algorithm
-
- Implement Stack with Queue, Implement Queue with Stack
- Exercise: Stack Problems on LeetCode
- Exercise: Bracket Problems on LeetCode
- Exercise: Queue Problems on LeetCode
- Monotonic Stack Code Template
- Exercise: Monotonic Stack Problems on LeetCode
- Monotonic Queue to Solve Sliding Window Problems
- Exercise: Monotonic Queue Implementation and Leetcode Problems
-
- Thinking Recursion Algorithms from Binary Tree Perspective
- Binary Tree in Action (Traversal)
- Binary Tree in Action (Construction)
- Binary Tree in Action (Post-order)
- Binary Tree in Action (Serialization)
- Binary Search Tree in Action (In-order)
- Binary Search Tree in Action (Basic Operations)
- Binary Search Tree in Action (Construction)
- Binary Search Tree in Action (Post-order)
-
- Chapter Introduction
- Exercise: Binary Tree Traversal I
- Exercise: Binary Tree Traversal II
- Exercise: Binary Tree Traversal III
- Exercise: Binary Tree Divide and Conquer I
- Exercise: Binary Tree Divide and Conquer II
- Exercise: Binary Tree Combine Two Views
- Exercise: Binary Tree Post-order I
- Exercise: Binary Tree Post-order II
- Exercise: Binary Tree Post-order III
- Exercise: Binary Tree Level I
- Exercise: Binary Tree Level II
- Exercise: Binary Search Tree I
- Exercise: Binary Search Tree II
-
- Implementing LRU Cache like Building a Lego
- Implementing LFU Cache like Building a Lego
- How to Deleting Array Element in O(1) Time
- Exercise: Hash Table Problems on LeetCode
- Exercise: Priority Queue Problems on LeetCode
- Implementing TreeMap/TreeSet
- Basic Segment Tree Implementation
- Dynamic Segment Tree Implementation
- Lazy Update Segment Tree Implementation
- Exercise: Segment Tree Problems
- Implementing Trie Tree
- Exercise: Trie Problems on LeetCode
- Designing an Exam Room Algorithm
- Exercise: Classic Design Problems on LeetCode
- Implement Huffman Coding Compression
- Implement Consistent Hashing Algorithm
- How to Implement a Calculator
- Implementing Median Algorithm with Two Binary Heaps
- Removing Duplicates from an Array (Hard Version)
-
- How to Determine a Bipartite Graph
- Hierholzer Algorithm to Find Eulerian Path
- Exercise: Eulerian Path
- Cycle Detection Algorithm
- Topological Sort Algorithm
- Union-Find Algorithm
- Exercise: Union-Find Problems on LeetCode
- Dijkstra Algorithm
- Dijkstra Algorithm with Restrictions
- Exercise: Dijkstra Problems
- A* Algorithm
- Kruskal Minimum Spanning Tree Algorithm
- Prim Minimum Spanning Tree Algorithm
-
-
DFS and Backtracking Algorithm
- Backtracking Algorithm Common Patterns and Code Template
- Backtracking in Action: Sudoku and N-Queens
- Implement Sudoku Cheat
- Backtracking Algorithm to Solve All Permutation/Combination/Subset Problems
- Some Questions About Backtracking and DFS Algorithms
- Solve All Island Problems with DFS
- Minesweeper Game II
- Ball and Box: Two Perspectives of Backtracking Enumeration
- Backtracking Algorithm Practice: Generating Valid Parentheses
- Backtracking Algorithm Practice: Partitioning k Subsets
- Exercise: Backtracking Problems on LeetCode I
- Exercise: Backtracking Problems on LeetCode II
- Exercise: Backtracking Problems on LeetCode III
-
-
Chapter 3. Dynamic Programming Algorithms
-
- Dynamic Programming Common Patterns and Code Template
- How to Design Transition Equations
- How to Determine the Base Case and Initial Values for Memoization?
- Two Perspectives of Dynamic Programming Enumeration
- How to Convert Backtracking to Dynamic Programming
- Optimize Space Complexity for Dynamic Programming
- Clarifying Some Questions About Dynamic Programming
-
- Classic DP: Minimum Path Sum
- Play Dungeon Game with DP
- Play Freedom Trail with DP
- Save Money on Your Trip: Weighted Shortest Path
- Multi-source shortest path: Floyd algorithm
- Classic DP: Regular Expression Matching
- Classic DP: Egg Drop
- Classic DP: Burst Balloons
- Classic DP: Game Theory
- One Method to Solve All House Robber Problems on LeetCode
- One Method to Solve all Stock Problems on LeetCode
-
-
Chapter 4. Other Common Techniques
-
- LeetCode Problems with One Line Solution
- Common Bit Manipulation Techniques
- Essential Math Techniques
- Minesweeper Game I
- Random Algorithms in Games
- Two Classic Factorial Problems on LeetCode
- How to Efficiently Count Prime Numbers
- How to Find Missing and Duplicate Elements
- Interesting Probability Problems
- Exercise: Math Tricks
-
- How to Efficiently Solve the Trapping Rain Water Problem
- One Article to Solve All Ugly Number Problems on LeetCode
- One Method to Solve Three Interval Problems on LeetCode
- Split Array into Consecutive Subsequences
- Pancake Sorting Algorithm
- String Multiplication Calculation
- How to Determine if a Rectangle is Perfect
-
-
-
- Frontend Development Introduction for AI Era
- Introduction to Modern Encryption
- Understand Session and Cookie
- Understanding JSON Web Token (JWT)
- Authentication vs. Authorization
- Understanding OAuth 2.0 Authorization Framework
- OAuth 2.0 and OIDC Authentication
- OAuth 2.0 and PKCE
- Understanding Single Sign-On (SSO)
- Certificate and CA
- TLS Key Exchange
- Mutual TLS Authentication
- Introduction to Linux File System
- Linux Processes, Threads and File Descriptors
- Pitfalls of Linux Pipeline
- Linux Shell Tips
- LSM Tree in Storage System
- Updating
-
