Personal LeetCode solutions (mostly JavaScript) with a study plan based on Labuladong's Quick Learning Plan.
目錄 / Table of Contents
基於 labuladong.online 速成目錄學習規劃 整理,用於在本倉庫中按框架刷題、追蹤進度。
建議配合 演算法速成路線圖(樹形結構,可展開教程與題單)使用。
| 項目 | 說明 |
|---|---|
| 適合誰 | 時間緊、要面試/筆試,想先掌握必考框架再刷公司題單 |
| 學習節奏 | 建議每天 1–2 小時;建議用時偏保守,整塊時間學習會更快 |
| 學習方法 | 先讀框架文章 → 再做題單;第一次以理解+模仿為主,不要死磕 |
| 本倉庫 | 做完題後可在根目錄找對應 LeetCode 編號檔案對照或補充解法 |
核心原則(來自原文)
- 先學框架,再刷題單 — 題單用於了解難度/類別和複習,不是入門起點
- 統一模板風格 — 學的是解題能力,不是背答案
- 先資料結構,再刷題 — 二元樹/遞迴是後續 DFS、回溯、DP 的基礎
- 不要跳過框架直接刷題 — 基礎不牢,遇到變體容易卡住
勾選 - [ ] 追蹤進度。框架文章標 核心,習題標 習題。
相對簡單,重點是建立直覺;二元樹與圖是後面刷題的地基。
- 環形陣列技巧 — O(1) 在陣列頭部插入/刪除
遞迴思維入門關鍵:後面所有遞迴本質都是二元樹遍歷。
- 二元搜尋樹的應用及視覺化 — 了解「左小右大」即可,技巧後面習題鞏固
- 二元堆核心原理及視覺化 — 理解優先級佇列、
swim/sink
刷題前可先讀:力扣/LeetCode 解題須知
- 核心 學習資料結構和演算法的框架思維 — 全站綱領,初讀不必死磕
| 類型 | 建議用時 | 內容 |
|---|---|---|
| 核心 | 1 天 | 雙指標技巧秒殺七道鏈表題目 |
| 習題 | 1 天 | 鏈表雙指標經典習題 |
| 核心 | 1 天 | 如何判斷回文鏈表 · 單鏈表的花式反轉方法匯總 |
- 雙指標框架
- 鏈表雙指標習題
- 回文鏈表 & 反轉匯總
| 類型 | 建議用時 | 內容 |
|---|---|---|
| 核心 | 0.5 天 | 雙指標技巧秒殺七道陣列題目 |
| 習題 | 1–2 天 | 二維陣列的花式遍歷技巧 · 陣列雙指標經典習題 |
| 核心 | 1 天 | 滑動視窗演算法核心程式碼模板 |
| 習題 | 1 天 | 滑動視窗演算法經典習題 |
| 核心 | 1–2 天 | 二分搜尋演算法核心程式碼模板 · 實際運用二分搜尋時的思維框架 |
| 核心 | 1–2 天 | 小而美的演算法技巧:前綴和陣列 · 小而美的演算法技巧:差分陣列 |
- 陣列雙指標框架
- 二維遍歷 & 雙指標習題
- 滑動視窗框架 & 習題
- 二分搜尋框架 & 思維框架
- 前綴和 & 差分陣列
字串題本質上是字元陣列,按陣列套路處理即可。
| 類型 | 建議用時 | 內容 |
|---|---|---|
| 核心 | 0.5 天 | 佇列實作堆疊以及堆疊實作佇列 |
| 習題 | 1–2 天 | 堆疊的經典習題 · 佇列的經典習題 |
| 核心 | 1–2 天 | 單調堆疊演算法模板解決三道例題 · 單調佇列結構解決滑動視窗問題 |
| 習題 | 1–2 天 | 單調堆疊的幾種變體及經典習題 |
- 堆疊/佇列互實作
- 堆疊 & 佇列習題
- 單調堆疊 & 單調佇列框架
- 單調堆疊習題
窮舉的核心抽象是樹結構。三種思維模式對應後續演算法:遍歷 → DFS/回溯;分解問題 → DP/分治;層序 → BFS。
| 類型 | 建議用時 | 內容 |
|---|---|---|
| 核心 | 0.5 天 | 一個視角+兩種思維模式搞定遞迴 |
| 核心 | 1 天 | 二元樹系列演算法核心綱領 — 先認真讀第一部分 |
| 核心 | 2–3 天 | 二元樹心法(思路篇) · 構造篇 · 序列化篇 |
| 習題 | 1 天 | 拓展:最近公共祖先系列解題框架 · 拓展:如何計算完全二元樹的節點數 |
| 習題 | 2 天 | 用「遍歷」思維解題 I · 用「分解問題」思維解題 I · 運用層序遍歷解題 I |
- 遞迴兩種思維模式
- 二元樹核心綱領
- 二元樹心法三篇
- LCA & 完全二元樹節點數
- 遍歷/分解/層序 習題 I
- 核心 二元搜尋樹心法(特性篇)
- 核心 二元搜尋樹心法(基操篇)
- 核心 二元搜尋樹心法(構造篇)
| 類型 | 建議用時 | 內容 |
|---|---|---|
| 習題 | 1 天 | 演算法就像搭樂高:手刻 LRU 演算法 — 必會 |
| 習題 | 1 天 | 拓展:如何實作一個計算機 — 可儲存模板備用 |
| 習題 | 1 天 | 更多經典設計習題 |
- LRU
- 計算機(可選儲存程式碼)
- 更多設計習題
| 類型 | 建議用時 | 內容 |
|---|---|---|
| 核心 | 1–2 天 | 環檢測演算法 · 拓撲排序演算法 · 二分圖判定演算法 |
| 核心 | 1 天 | Union Find 併查集原理 · Union-Find 併查集演算法 — 建議儲存 UF 模板 |
| 核心 | 1 天 | 最小生成樹問題概覽 · Kruskal 最小生成樹演算法 |
| 核心 | 0.5 天 | 圖結構最短路演算法概覽 |
| 核心 | 1 天 | Dijkstra 演算法模板 · Dijkstra 拓展:帶限制的最短路問題 · Dijkstra 演算法習題 |
- 環檢測/拓撲排序/二分圖
- 併查集原理 & 實作
- 最小生成樹 & Kruskal
- 最短路概覽
- Dijkstra 模板 & 習題
| 類型 | 建議用時 | 內容 |
|---|---|---|
| 核心 | 1–2 天 | 回溯演算法解題套路框架 · 回溯演算法實踐:數獨和 N 皇后問題 |
| 核心 | 1–2 天 | 回溯演算法秒殺所有排列/組合/子集問題 |
| 核心 | 1 天 | 一文秒殺所有島嶼題目 · 回答 DFS 和回溯演算法的若干疑問 |
| 習題 | 2 天 | 回溯演算法經典習題 I(時間緊可只做精選題) |
- 回溯框架 & 數獨/N 皇后
- 排列/組合/子集萬能框架
- 島嶼 DFS & DFS vs 回溯
- 回溯習題 I
| 類型 | 建議用時 | 內容 |
|---|---|---|
| 核心 | 1 天 | BFS 演算法解題套路框架 |
| 習題 | 2 天 | BFS 經典習題 I · BFS 經典習題 II(時間緊可精選) |
- BFS 框架
- BFS 習題
| 類型 | 建議用時 | 內容 |
|---|---|---|
| 核心 | 1–2 天 | 動態規劃解題套路框架 · 動態規劃設計:最長遞增子序列 |
| 核心 | 1–2 天 | base case 和備忘錄的初始值怎麼定? · 最優子結構原理和 dp 陣列遍歷方向 |
| 習題 | 1–2 天 | 經典動態規劃:編輯距離 · 動態規劃設計:最大子陣列 · 經典動態規劃:最長公共子序列 |
| 習題 | 1–2 天 | 經典動態規劃:0-1 背包問題 · 子集背包問題 · 完全背包問題 |
- DP 框架 & LIS
- base case & 遍歷方向
- 編輯距離/最大子陣列/LCS
- 三種背包
若目標公司明確不考 DP,可跳過本節,把時間給其他專題。
- 核心 貪心演算法原理及應用
- 核心 分治演算法詳解
- 習題 一行程式碼就能解決的演算法題 · 談談遊戲中的隨機演算法
- 習題 如何高效尋找質數 · 必知必會數學技巧
- 習題 掃描線技巧:安排會議室 · 如何高效解決接雨水問題 · 一文秒殺所有醜數系列問題
- 習題 帶權重的隨機選擇演算法 · 一個方法團滅 nSum 問題
- 十大排序演算法導讀 — 筆試少寫排序程式碼,但需了解原理、複雜度與適用場景
| 階段 | 建議用時 | 完成 |
|---|---|---|
| 一、資料結構 | 5–7 天 | ☐ |
| 二、刷題總綱 | 0.5 天 | ☐ |
| 鏈表 | 3 天 | ☐ |
| 陣列 | 6–9 天 | ☐ |
| 佇列/堆疊 | 4–7 天 | ☐ |
| 二元樹 & 遞迴 | 7–8 天 | ☐ |
| 二元搜尋樹 | 2–3 天 | ☐ |
| 字典樹 | 1–2 天 | ☐ |
| 資料結構設計 | 3 天 | ☐ |
| 圖演算法 | 5–6 天 | ☐ |
| DFS/回溯 | 5–7 天 | ☐ |
| BFS | 3 天 | ☐ |
| 動態規劃 | 5–8 天 | ☐ |
| 貪心 | 1 天 | ☐ |
| 分治 | 1 天 | ☐ |
| 數學 | 2–3 天 | ☐ |
| 其他經典題 | 2–4 天 | ☐ |
| 排序 | 1 天 | ☐ |
| 合計(約) | 55–75 天 |
按每天 1–2 小時估算;整塊時間學習可顯著縮短。
按專題列出部分已存在的本地檔案,刷完對應章節後可回來對照:
| 專題 | 本倉庫檔案 |
|---|---|
| 雜湊/雙指標 | 1. Two Sum.js |
| 鏈表 | 2. Add Two Numbers.js, 206. Reverse Linked List.js |
| 滑動視窗 | 3. Longest Substring Without Repeating Characters.js, 239. Sliding Window Maximum.js |
| 堆疊 | 20. Valid Parentheses.js |
| 雙指標/nSum | 15. 3Sum.js |
| 回溯 | 46. Permutations.js, 78. Subsets.js |
| DFS 島嶼 | 200. Number of Islands.js, 695. Max Area of Island.js |
| 字典樹 | 208. Implement Trie (Prefix Tree).js |
| 堆積 | 215. Kth Largest Element in an Array.js |
| 併查集 | 547. Friend Circles.js, 721. Accounts Merge.js |
| 設計 | 380. Insert Delete GetRandom O(1).js, 535. Encode and Decode TinyURL.js |
| 接雨水 | 42. Trapping Rain Water.js |
| 動態規劃 | 198. House Robber.js, 64. Minimum Path Sum.js |
| 圖/最短路 | 787. Cheapest Flights Within K Stops.js |
來源:Labuladong《速成目錄學習規劃》,頁面更新於 2026/06/19
Based on labuladong.online Quick Learning Plan. Use this guide to practice by framework and track progress in this repository.
Pair it with the Algorithm Quick Learning Roadmap (tree view with tutorials and problem lists).
| Item | Description |
|---|---|
| Who It's For | Short on time, preparing for interviews or coding tests, want to master essential frameworks before company problem lists |
| Study Pace | ~1–2 hours per day; time estimates are conservative — dedicated blocks speed things up |
| Learning Method | Read framework articles first → then problem sets; first pass: understand and imitate, don't grind |
| This Repository | After solving, compare or add solutions using LeetCode-numbered files in the repo root |
Core Principles (from the original)
- Learn frameworks first, then problem lists — lists are for gauging difficulty/categories and review, not as a starting point
- Unified template style — build problem-solving skill, not memorization
- Data structures before problems — binary trees and recursion underpin DFS, backtracking, and DP
- Don't skip frameworks and jump straight to problems — weak foundations fail on variants
Check off - [ ] items to track progress. Framework articles are marked Core; drills are marked Practice.
Relatively straightforward — focus on intuition. Binary trees and graphs are the foundation for later problem-solving.
- Circular Array Technique — O(1) insert/delete at array head
- Hash Table Core Principles
- Strengthening Hash Tables with Linked Lists (LinkedHashMap)
- Strengthening Hash Tables with Arrays (ArrayHashMap)
Key to recursive thinking: all recursion is essentially binary tree traversal.
- Binary Tree Basics & Common Types
- Recursive / Level-Order Traversal of Binary Trees
- Recursive / Level-Order Traversal of N-ary Trees
- When to Use DFS vs BFS
- Applications & Visualization of Binary Search Trees — know "left smaller, right larger"; techniques reinforced in practice
- Binary Heap Core Principles & Visualization — understand priority queue,
swim/sink
- Basic Graph Theory Terminology
- Graph Structure Basics & General Implementation
- DFS / BFS Traversal of Graphs
Before diving in, read: LeetCode Problem-Solving Guide
- Core Framework Thinking for Data Structures & Algorithms — site-wide overview; don't grind on first read
| Type | Suggested Time | Content |
|---|---|---|
| Core | 1 day | Two-Pointer Techniques: Seven Linked List Problems |
| Practice | 1 day | Classic Linked List Two-Pointer Problems |
| Core | 1 day | How to Detect a Palindrome Linked List · Creative Ways to Reverse a Singly Linked List |
- Two-pointer framework
- Linked list two-pointer practice
- Palindrome linked list & reversal summary
| Type | Suggested Time | Content |
|---|---|---|
| Core | 0.5 day | Two-Pointer Techniques: Seven Array Problems |
| Practice | 1–2 days | Creative 2D Array Traversal Techniques · Classic Array Two-Pointer Problems |
| Core | 1 day | Sliding Window Algorithm Core Template |
| Practice | 1 day | Classic Sliding Window Problems |
| Core | 1–2 days | Binary Search Core Template · Mental Framework for Binary Search in Practice |
| Core | 1–2 days | Prefix Sum Arrays · Difference Arrays |
- Array two-pointer framework
- 2D traversal & two-pointer practice
- Sliding window framework & practice
- Binary search framework & mental model
- Prefix sum & difference array
String problems are essentially character arrays — treat them with array techniques.
| Type | Suggested Time | Content |
|---|---|---|
| Core | 0.5 day | Implement Stack with Queue & Queue with Stack |
| Practice | 1–2 days | Classic Stack Problems · Classic Queue Problems |
| Core | 1–2 days | Monotonic Stack Template: Three Example Problems · Monotonic Queue for Sliding Window Problems |
| Practice | 1–2 days | Monotonic Stack Variants & Classic Problems |
- Stack/queue mutual implementation
- Stack & queue practice
- Monotonic stack & monotonic queue frameworks
- Monotonic stack practice
The core abstraction of brute force is tree structure. Three thinking modes map to later algorithms: traversal → DFS/backtracking; divide & conquer → DP/divide-and-conquer; level-order → BFS.
| Type | Suggested Time | Content |
|---|---|---|
| Core | 0.5 day | One Perspective + Two Thinking Modes to Master Recursion |
| Core | 1 day | Binary Tree Algorithm Core Guide — read Part 1 carefully first |
| Core | 2–3 days | Binary Tree Mastery (Thinking) · Construction · Serialization |
| Practice | 1 day | Extension: Lowest Common Ancestor Framework · Extension: Counting Nodes in a Complete Binary Tree |
| Practice | 2 days | Solve with Traversal Thinking I · Solve with Divide-and-Conquer Thinking I · Solve with Level-Order Traversal I |
- Two recursive thinking modes
- Binary tree core guide
- Binary tree mastery (three articles)
- LCA & complete binary tree node count
- Traversal / divide / level-order practice I
- Core Trie Fundamentals
- Core Trie Implementation
| Type | Suggested Time | Content |
|---|---|---|
| Practice | 1 day | Build LRU from Scratch — must know |
| Practice | 1 day | Extension: How to Build a Calculator — save template for reuse |
| Practice | 1 day | More Classic Design Problems |
- LRU
- Calculator (optional: save template)
- More design practice
| Type | Suggested Time | Content |
|---|---|---|
| Core | 1–2 days | Cycle Detection · Topological Sort · Bipartite Graph Detection |
| Core | 1 day | Union-Find Principles · Union-Find Algorithm — save UF template |
| Core | 1 day | Minimum Spanning Tree Overview · Kruskal's Minimum Spanning Tree Algorithm |
| Core | 0.5 day | Shortest Path Algorithms Overview |
| Core | 1 day | Dijkstra's Algorithm Template · Dijkstra Extension: Constrained Shortest Path · Dijkstra Practice Problems |
- Cycle detection / topological sort / bipartite graph
- Union-Find principles & implementation
- Minimum spanning tree & Kruskal
- Shortest path overview
- Dijkstra template & practice
| Type | Suggested Time | Content |
|---|---|---|
| Core | 1–2 days | Backtracking Problem-Solving Framework · Backtracking in Practice: Sudoku & N-Queens |
| Core | 1–2 days | Master All Permutation / Combination / Subset Problems with Backtracking |
| Core | 1 day | Master All Island Problems in One Article · FAQ: DFS vs Backtracking |
| Practice | 2 days | Classic Backtracking Problems I (pick essentials if short on time) |
- Backtracking framework & Sudoku/N-Queens
- Permutation/combination/subset universal framework
- Island DFS & DFS vs backtracking
- Backtracking practice I
| Type | Suggested Time | Content |
|---|---|---|
| Core | 1 day | BFS Problem-Solving Framework |
| Practice | 2 days | Classic BFS Problems I · Classic BFS Problems II (pick essentials if short on time) |
- BFS framework
- BFS practice
| Type | Suggested Time | Content |
|---|---|---|
| Core | 1–2 days | Dynamic Programming Framework · DP Design: Longest Increasing Subsequence |
| Core | 1–2 days | How to Set Base Cases & Memo Initial Values? · Optimal Substructure & DP Array Traversal Direction |
| Practice | 1–2 days | Classic DP: Edit Distance · DP Design: Maximum Subarray · Classic DP: Longest Common Subsequence |
| Practice | 1–2 days | Classic DP: 0-1 Knapsack · Subset Knapsack · Unbounded Knapsack |
- DP framework & LIS
- Base case & traversal direction
- Edit distance / max subarray / LCS
- Three knapsack variants
If your target company explicitly does not test DP, skip this section and allocate time elsewhere.
- Practice One-Liner Algorithm Problems · Random Algorithms in Games
- Practice How to Efficiently Find Prime Numbers · Essential Math Techniques
- Practice Scanline Technique: Meeting Rooms · How to Efficiently Solve Trapping Rain Water · Master All Ugly Number Problems
- Practice Random Pick with Weight · One Method to Solve All nSum Problems
- Top Ten Sorting Algorithms Guide — rarely implement sorts in tests, but know principles, complexity, and use cases
| Phase | Suggested Time | Done |
|---|---|---|
| Part 1: Data Structures | 5–7 days | ☐ |
| Problem-solving overview | 0.5 day | ☐ |
| Linked lists | 3 days | ☐ |
| Arrays | 6–9 days | ☐ |
| Queue / Stack | 4–7 days | ☐ |
| Binary trees & recursion | 7–8 days | ☐ |
| Binary search tree | 2–3 days | ☐ |
| Trie | 1–2 days | ☐ |
| Data structure design | 3 days | ☐ |
| Graph algorithms | 5–6 days | ☐ |
| DFS / Backtracking | 5–7 days | ☐ |
| BFS | 3 days | ☐ |
| Dynamic programming | 5–8 days | ☐ |
| Greedy | 1 day | ☐ |
| Divide and conquer | 1 day | ☐ |
| Mathematics | 2–3 days | ☐ |
| Other classic problems | 2–4 days | ☐ |
| Sorting | 1 day | ☐ |
| Total (approx.) | 55–75 days |
Estimated at 1–2 hours per day; dedicated study blocks can significantly shorten the timeline.
Local files to compare after completing each section:
| Topic | Local Files |
|---|---|
| Hash table / two pointers | 1. Two Sum.js |
| Linked lists | 2. Add Two Numbers.js, 206. Reverse Linked List.js |
| Sliding window | 3. Longest Substring Without Repeating Characters.js, 239. Sliding Window Maximum.js |
| Stack | 20. Valid Parentheses.js |
| Two pointers / nSum | 15. 3Sum.js |
| Backtracking | 46. Permutations.js, 78. Subsets.js |
| DFS islands | 200. Number of Islands.js, 695. Max Area of Island.js |
| Trie | 208. Implement Trie (Prefix Tree).js |
| Heap | 215. Kth Largest Element in an Array.js |
| Union-Find | 547. Friend Circles.js, 721. Accounts Merge.js |
| Design | 380. Insert Delete GetRandom O(1).js, 535. Encode and Decode TinyURL.js |
| Trapping rain water | 42. Trapping Rain Water.js |
| Dynamic programming | 198. House Robber.js, 64. Minimum Path Sum.js |
| Graph / shortest path | 787. Cheapest Flights Within K Stops.js |
- Company problem lists — gauge difficulty and categories; use for review
- Full curriculum — see Complete Learning Plan if you have more time
- Install practice plugins — Chrome / VS Code / JetBrains for in-page solution walkthroughs
Source: Labuladong "Quick Learning Plan" — page last updated 2026/06/19