Introduction
If the full score is 100, regardless of your foundation, this site can help you reach a level of 85 in the shortest time possible.
Because this site teaches a templated, structured way of thinking, the 85 score you achieve is stable and repeatable, independent of luck. This means for problems with difficulty less than 85, you can solve them methodically, and for those with difficulty greater than 85, inspiration and luck are needed.
What does a score of 85 mean?
For reference, assume you studied computer science in college, attended mandatory data structures and algorithms courses, and mainly used various development frameworks at work without practicing algorithm problems. Your level would be around 30-40. That's true because algorithms can be seen as an independent ability, unrelated to programming experience, requiring dedicated practice.
So don't think a score of 85 is low; it's more than enough for technical job interviews and general competitions. Also, don't fear algorithms; just use the correct methods and spend some time practicing, and improving your algorithm skills is quite easy.
Site Structure
Introduction
Tools: Tools and Algorithm Visualization
Chrome Extension for LeetCode vscode Plugin for LeetCode JetBrains Plugin for LeetCode Algorithm Visualization Introduction Subscribe to this Algo Notes
Study Plans for Beginners and Quick Mastery
Learning Plan for Beginners Learning Plan for Quick Mastery How to Learn Algorithms Efficiently How to Practice Algo Visualization Cheat Sheet
Getting Started: Programming Language Basics
Chapter Introduction C++ Basics Java Basics Golang Basics Python Basics JS Basic to Use the Algo Visualization LeetCode Guide Let's Have Fun with LeetCode
Basics: Data Structures and Sorting
Implement Dynamic Arrays
Implement Single/Double Linked List
Array and LinkedList Variations
Implement Queue and Stack
Implement HashMap
Hash Table Variations
Binary Tree Structure and Traversal
Binary Tree Variations
Graph Theory and Traversals
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
Updating
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 Binary Search Algorithm Code Template 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 Thinking Recursion Algorithms from Binary Tree Perspective 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
Linked List
Array
Two Pointer Techniques for Array Problems Tricks to Traverse a 2D Array One Trick to Solve All N-Sum Problems Exercise: Two Pointer Techniques for Array Prefix Sum Array Technique Exercise: Prefix Sum Techniques Difference Array Technique Sliding Window Algorithm Code Template Exercise: Sliding Window In Action Sliding Window Application: Rabin Karp String Matching Algorithm Binary Search Algorithm Code Template Binary Search in Action Exercise: Binary Search Algorithm Weighted Random Selection Algorithm Advantage Shuffle Algorithm
Classic Stack/Queue 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
Binary Tree
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)
Master Binary Tree Problems
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
Binary Tree Follow-up
Design Data Structures
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 a Twitter Feed Designing an Exam Room Algorithm Exercise: Classic Design Problems on LeetCode How to Implement a Calculator Implementing Median Algorithm with Two Binary Heaps Removing Duplicates from an Array (Hard Version)
Graph
Cycle Detection and Topological Sort Algorithm Searching for a Celebrity How to Determine a Bipartite Graph Union-Find Algorithm Exercise: Union-Find Problems on LeetCode Kruskal Minimum Spanning Tree Algorithm Prim Minimum Spanning Tree Algorithm Dijkstra Algorithm Template and Applications Exercise: Dijkstra Problems
Chapter 2. Brute Force Search
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 Ball and Box: Two Perspectives of Backtracking Enumeration Some Questions About Backtracking and DFS Algorithms Solve All Island Problems with DFS 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
BFS Algorithm
Chapter 3. Dynamic Programming Algorithms
Basic DP Techniques
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
Subsequence Problems
Knapsack Problems
Dynamic Programming Game
Classic DP: Minimum Path Sum Play Dungeon Game with DP Play Freedom Trail with DP Save Money on Your Trip: Weighted Shortest Path 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
Greedy
Chapter 4. Other Common Techniques
Mathematical Techniques
LeetCode Problems with One Line Solution Common Bit Manipulation Techniques Random Algorithms in Games Two Classic Factorial Problems on LeetCode How to Efficiently Count Prime Numbers How to Efficiently Perform Modular Exponentiation How to Find Missing and Duplicate Elements Interesting Probability Problems Exercises: Math Tricks
Classic Interview Problems
Tips for Algorithmic Exams 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
Appendix
Reading Approach
For readers with urgent time constraints (preparation time < 30 days), follow the order in the Quick Mastery Plan.
For readers with some foundation (solved > 300 problems), Chapter 0 is a must-read; other chapters can be selected as needed.
For beginners, read according to the site's directory in a steady manner. The site is compatible with both PC and mobile:

Site Content
The site offers tutorials with pictures and videos, mainly divided into three categories:
1️⃣ Data Structure Tutorials (about 10% of site content)
Mainly focused in Introduction to Data Structures and Sorting. This section explains sorting algorithms and the core principles and code implementations of classic data structures. It generally doesn't include algorithm problems and aims to help readers understand the principles of commonly used data structures at work and those unique to algorithm problems, which can be directly applied in future tasks.
2️⃣ Classic Algorithm Frameworks Explained with Examples (about 50% of site content)
For some classic algorithm frameworks or problems, I will use entire articles to explain them in detail with specific examples to help you understand the principles. Generally, each article includes 2-5 examples that you can solve as you read.
3️⃣ Exercise Chapters to Help You Master Algorithm Frameworks (about 40% of site content)
Content marked with 【Exercise】
in the directory belongs to the exercise section, usually following the algorithm framework content. Exercises are problems that can directly apply frameworks, aiming to help you develop muscle memory through repetition and thoroughly master a type of problem-solving method. Each intensive practice includes 5-10 exercises, allowing you to solve them quickly after mastering the algorithm framework.
This site can guide you through solving hundreds of free LeetCode problems. Most of these problems are for practicing framework thinking, and once you master the algorithm frameworks, they can be solved in minutes, finishing them all unconsciously.
About the Site
Keep up with the latest address of our site, continuously updated: labuladong.online
The site supports both mobile and PC reading, and it's recommended to open it directly in WeChat on mobile for easy one-click login.
The site guides you through solving hundreds of free LeetCode problems with a framework mindset, ensuring that your algorithmic thinking won't degrade and can be quickly regained even after years.
I highly value everyone's learning experience and continuously update and optimize the site's content. There is an Update Log and a Bug Feedback link at the top.
Expired URLs/PDFs/Content
As I continuously update, optimize, and correct algorithm tutorials, some historical content and sites should be discarded, as more concise and quality content is now available for your learning.
Algorithm tutorials I published on other platforms are outdated and no longer updated.
The site addresses I used are no longer maintained, including:
Past PDFs are also outdated, including: "labuladong's Algorithm Cheatsheet", "labuladong's Problem-Solving Notes", "labuladong's Algorithm Secrets", etc.
LeetCode Problem List
At the request of some readers, I compiled a list of problems covered on the site. After installing the Chrome Plugin, you can open this list to see that all problems have site-provided solutions/ideas.
However, please note that I personally think this list is not very useful and do not recommend practicing directly from it because the problem order is random, making it hard to learn progressively or focus on specific topics. And it's unnecessary to complete all these problems; once you master the core algorithm framework, most problems can be solved quickly without deliberate practice:
LeetCode | LeetCode |
---|---|
https://leetcode.cn/problem-list/59jEaTgw/ | https://leetcode.com/list/9zwo3ww5/ |
I suggest following the Beginner's Learning Plan or Quick Mastery Learning Plan for structured learning. These plans include categorized problem lists, and the VSCode Plugin and JetBrains Plugin integrate these learning plans for convenient use by readers in need.

About the Author
I am labuladong, the author of the fucking-algorithm repository, commonly referred to as "Dong Ge" by readers. I pioneered the framework thinking approach to problem-solving and have topped GitHub Trending multiple times, currently with over 125k stars.
My personal style focuses on being small and precise, not large and comprehensive, so the site targets only algorithm problem-solving, hitting the mark accurately to help readers master algorithms thoroughly in the shortest time possible.
Site Subscription is the only paid project, allowing access to all site content and tools with the cost of a meal, providing the smoothest learning experience.
Practical Features of the Site
1. Supports Algorithm Visualization
All solutions in this site and its accompanying plugins are equipped with an algorithm visualization panel underneath the code, allowing for an intuitive view of the algorithm's execution process, aiding in understanding the logic.
For instance, in the algorithm Calculate the Start of a Cycle in a Singly Linked List, you can repeatedly click if (fast == slow) break
to see how the fast and slow pointers meet; clicking on while (slow != fast)
lets you observe their synchronized movement towards the cycle's start:
Example 1: Color System and Interaction
The visualization panel enhances complex data structures and recursive algorithms. Here is a DFS Traversal Algorithm on Graphs, finding all paths from node 0
to node 4
. You can click if (s === n - 1)
repeatedly to observe the graph traversal and the growth of the recursion tree:
Example 2: Complex Structures and Recursion
The visualization panel can present data structures in various forms, facilitating readers' understanding.
For example, below is an array represented as a histogram, demonstrating the Insertion Sort process. You can click the play button in the upper left corner to speed up playback and view the sorting process:
Example 3: Sorting Algorithms
The visualization panel significantly reduces the effort required to understand complex algorithms, supporting all data structures and algorithms, with only a few examples shown here. More classic algorithm visualizations can be found on the Algorithm Visualization Quick Reference Page.
2. Combine with Game Engines for Practical Application
The visualization panel allows readers to intuitively grasp the execution process of algorithms. However, merely practicing problems can be monotonous, so I aim to connect algorithms with real life to further showcase their charm and foster a genuine interest in algorithms.
One idea is to integrate algorithms with games. Instead of using hands to play games, can algorithms be used to operate them?
Thus, I will design classic mini-games, abstracting their algorithmic components, providing a game scenario for readers to write algorithms for the game engine to execute, ultimately resulting in a playable game or completing a challenging task.
This approach not only gives readers a strong sense of accomplishment but also provides insight into the application of algorithms in real-world scenarios, leading to a deeper understanding.
For example, below is a snake game where you write the logic for the snake's movement and food consumption to make the game run. While it may seem complex, it can be achieved using Basic Operations of Singly Linked Lists:
Snake Game Demonstration
The gaming feature is still in the beta stage; I have several game ideas that will be gradually released on the website.
3. Supports All Major Programming Languages
All solution codes on this site and its accompanying plugins support common programming languages such as Java, C++, Python, Golang, and JavaScript, catering to a wide range of readers.
The Java code is written by me, while other languages are assisted by chatGPT, all of which have been personally verified and debugged to ensure correctness and consistency.
The site and plugins support code image annotations. For complex code blocks, a lightbulb icon may appear, and hovering over it will reveal an image to aid understanding:
class Solution {
public ListNode detectCycle(ListNode head) {
ListNode fast, slow;
fast = slow = head;
while (fast != null && fast.next != null) {
fast = fast.next.next;
slow = slow.next;
if (fast == slow) break;
}
// the above code is similar to the hasCycle function
if (fast == null || fast.next == null) {
// fast encountering a null pointer means there is no cycle
return null;
}
// reassign to the head node
slow = head;
// move fast and slow pointers at the same
// pace, the intersection point is the cycle's
while (slow != fast) {
fast = fast.next;
slow = slow.next;
}
return slow;
}
}
class Solution {
public:
ListNode *detectCycle(ListNode *head) {
ListNode *fast, *slow;
fast = slow = head;
while (fast != nullptr && fast->next != nullptr) {
fast = fast->next->next;
slow = slow->next;
if (fast == slow) break;
}
// the above code is similar to the hasCycle function
if (fast == nullptr || fast->next == nullptr) {
// if fast encounters a null pointer, it means there is no cycle
return nullptr;
}
// reset to the head node
slow = head;
// move the fast and slow pointers forward in
// sync, the intersection point is the start of
while (slow != fast) {
fast = fast->next;
slow = slow->next;
}
return slow;
}
};
class Solution:
def detectCycle(self, head: ListNode):
fast, slow = head, head
while fast and fast.next:
fast = fast.next.next
slow = slow.next
if fast == slow:
break
# the above code is similar to the hasCycle function
if not fast or not fast.next:
# if fast encounters a null pointer, it means there is no cycle
return None
# reset the pointer to the head node
slow = head
# both fast and slow pointers move forward in
# sync, the intersection point is the start of
while slow != fast:
fast = fast.next
slow = slow.next
return slow
func detectCycle(head *ListNode) *ListNode {
fast, slow := head, head
for fast != nil && fast.Next != nil {
fast = fast.Next.Next
slow = slow.Next
if fast == slow {
break
}
}
// the above code is similar to the hasCycle function
if fast == nil || fast.Next == nil {
// if fast encounters a null pointer, it means there is no cycle
return nil
}
// reset the pointer to the head node
slow = head
// move the fast and slow pointers forward in
// sync, the intersection point is the start of the
for slow != fast {
fast = fast.Next
slow = slow.Next
}
return slow
}
var detectCycle = function(head) {
let fast, slow;
fast = slow = head;
while (fast !== null && fast.next !== null) {
fast = fast.next.next;
slow = slow.next;
if (fast == slow) break;
}
// the above code is similar to the hasCycle function
if (fast === null || fast.next === null) {
// if fast encounters a null pointer, it means there is no cycle
return null;
}
// reset the pointer to the head node
slow = head;
// move the fast and slow pointers forward in
// sync, the intersection point is the start of the
while (slow !== fast) {
fast = fast.next;
slow = slow.next;
}
return slow;
};
4. Other Practical Features
Supports Reading History. In the sidebar and within articles, unread articles display an
Supports Focus Mode. When accessing the site on a computer, a "Focus Mode" switch is available in the upper right corner. Enabling it blurs the sidebar and top bar, helping to concentrate attention or learn discreetly at work.
Supports Site-wide Search. The search box in the upper right corner supports site-wide search, allowing you to search for explanations by entering LeetCode problems, titles, or links.
5. Accompanying Problem-Solving Plugins for Learning
To cater to different readers' needs, I have developed and maintained problem-solving plugins for the site, enabling readers to practice problems in their preferred code editor, facilitating leisure learning.
The problem-solving plugins integrate Beginner's Directory and Quick Mastery Directory, support local code debugging, and provide easy access to the site's thought process explanations, visualization panels, image annotations, and other practical features.
The problem-solving plugins are not mandatory, but I recommend installing the Chrome browser extension because you may frequently switch to LeetCode pages while reading the site, and the Chrome extension can offer some assistance. You can choose to install the vscode/Jetbrain plugins based on your problem-solving needs.
For installation and usage of the various problem-solving plugins, see Chrome Plugin, vscode Plugin, and Jetbrain Plugin.