fucking-algorithm

刷算法全靠套路,认准 labuladong 就够了!English version supported! Crack LeetCode, not only how, but also why.

24 articles 133k View on GitHub ↗
24 articles
When Is a Greedy Algorithm Appropriate Versus Dynamic Programming?

Learn when to use greedy algorithms versus dynamic programming. Discover the greedy-choice property and overlapping sub-problems to optimize your solutions.

deep-dive
Feb 25, 2026
How to Solve Interval Scheduling Problems Using a Greedy Approach

Master interval scheduling problems with a greedy approach. Learn to efficiently select non-overlapping intervals by sorting and picking based on end times. Maximize your interval selections.

how-to-guide
Feb 25, 2026
How to Implement a Trie for Efficient Prefix Matching and Autocomplete

Implement a Trie for lightning-fast prefix matching and autocomplete. Discover O(L) lookup times for efficient string operations and boost your application's performance.

how-to-guide
Feb 25, 2026
How to Reverse a Linked List in Groups of k Nodes: Recursive and Iterative Solutions

Learn to reverse a linked list in groups of k nodes with recursive and iterative solutions. Master reversing segments and reconnecting them efficiently.

how-to-guide
Feb 25, 2026
Data Structures and Algorithms for Designing a Twitter Feed: A Complete Implementation Guide

Learn how to design a Twitter feed using data structures like linked lists and hash sets, plus algorithms like max-heaps. Implement a unified timeline efficiently.

how-to-guide
Feb 25, 2026
How to Use Heaps and Priority Queues for Median Finding in a Data Stream

Find the median of a data stream efficiently using two heaps. Learn how heaps and priority queues enable O(log n) insertion and O(1) median retrieval for dynamic data.

how-to-guide
Feb 25, 2026
How to Validate, Search, and Insert Elements in a Binary Search Tree (BST)

Master binary search tree BST validation, search, and insertion in O(h) time. Learn efficient recursive traversal techniques for rapid data management. Unlock BST performance now.

how-to-guide
Feb 25, 2026
How to Calculate Edit Distance Between Two Strings Using DP

Learn to calculate edit distance between two strings using dynamic programming. This guide explains DP transitions and O(m*n) complexity for efficient string comparison.

how-to-guide
Feb 25, 2026
Dynamic Programming Approaches for Stock Trading Problems: A Unified Framework

Master dynamic programming for stock trading with labuladong's unified framework. Solve all variations using a 3D DP state, optimizing to O(1) space for common constraints.

deep-dive
Feb 25, 2026
How to Solve Knapsack Problems (0-1, Unbounded, Subset) Using Dynamic Programming

Master knapsack problems like 0-1, unbounded, and subset using dynamic programming. Learn optimal O(N·W) time and O(W) space solutions. Explore the DP state and recurrence relations used.

tutorial
Feb 25, 2026
How Prefix Sums Optimize Array Range Queries: O(1) Range Sum with O(n) Preprocessing

Learn how prefix sums optimize array range queries achieving O(1) range sums after O(n) preprocessing. Discover constant-time lookups with simple subtraction.

tutorial
Feb 25, 2026
Union-Find Data Structure: Implementation, Optimizations, and Use Cases

Master the Union-Find data structure. Explore its efficient implementation, path compression and union-by-size optimizations, and diverse use cases in algorithms and graph problems.

deep-dive
Feb 25, 2026

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →