👉 2020 ~ 2022 两周年纪念!已达成 1000+ LeetCode题 & LeetCode Contest World Rating 前 10% 小成就。
🎉 目前已拿到多家互联网后端/国企/银行软开的21届offer,笔试及面试手撕环节 AC 率 95%。
希望能帮助到还在准备北美SDE、国内秋招&春招技术开发岗的各位,欢迎大家pull request一起完善!
👉 有需要 LeetCode 会员账号、或需要解锁查看内容的、有问题都欢迎私信我,我的会员2022年11月到期。
我的LeetCode刷题、思路和代码总结,以及常见算法模板。欢迎在仓库内搜索题解(since 2020, 目前工作繁忙,更新较慢).
欢迎各位star!便于日常学习/面试/笔试前复习,重在积累和思路,因为题目是做不完!
- 初期:题解标题下有原题链接,先自我思考5-10分钟,没有思路的话,立即“抄答案”,备考前期不要贪题量,每周保证每个 Tag 背熟 3 ~ 5 个 Medium 难度的经典题。
- 背熟!!:算法模板代码👆(二分查找、单链表、堆排序、归并排序、快速排序、并查集、Trie 前缀树等)
- 经典模板题!:Tag 分类👇,以及:
- 各种双指针问题、栈(Stack/深搜,题号232, 150, 224, 20, 1472, 1249)、队列(Queue/宽搜/二叉树层序遍历,225, 346, 1429, 54)、堆(Heap/Priority Queue/前K最值问题,347, 23, 692, 895, 295, 1438(Google原题))
- 84. 直方图最大矩形
- 53. 最大连续子数组的和、300. 最长上升子序列 LIS、最长上升公共子序列、最长连续不重复的子序列
- 股票买卖系列
- 经典DFS/BFS搜索问题:0/1二维矩阵求岛屿数量(LC 200),迷宫最短路、太平洋大西洋
- 更新中....
- 中期:能够举一反三,在 LeetCode 搜索类似题目,最好能够一边讲思路、一边写代码。
- 后期突击:强烈建议大家使用 codeTop。
Tag | 题解分类 |
---|---|
Array | 数组 |
Two Pointers | 双指针问题 |
DP | 动态规划 |
Tree | 树 |
Linked List | 链表 |
Subset | 子集问题 |
DFS | 深度优先搜索 |
BFS | 广度优先搜索 |
Binary Search | 二分查找 |
Greedy | 贪心算法 |
Graph | 图 |
Sliding Window | 滑动窗口问题 |
Merge Intervals | 区间合并问题 |
BackTracking | 回溯 |
Stack | 栈 |
Bit Manipulation | 位运算 |
Heap | 堆 |
Design | 设计题 |
String | 字符串 |
Palindrome | 回文串 |
- Pair with Target Sum (模板)
- Remove Duplicates (模板)
- Triplet Sum to Zero (模板)
- Subarrays with Product Less than a Target (medium)
- Dutch National Flag Problem (medium) / 三色旗 / 颜色分类
- 4Sum
- 1537. Get the Maximum Score (Hard)
- 42. Trapping Rain Water
- 434. Number of Segments in a String
- 10. Regular Expression Matching 字符匹配
- 45. Jump Game 2
- 91. Decode Ways
- 198. House Robber
- 337. House Robber III
- 256. Paint House
- 265. Paint House 2 (Hard)
- 221. Maximal Square (Medium)
- 494. Target Sum (Medium)
- 746. Min Cost Climbing Stairs
- 279. Perfect Squares
- 63. Unique Paths
- 322. Coin Change
- 518. Coin Change 2
- 486. Predict the Winner
- 377. Combination Sum IV
- 131. Palindrome Partitioning 最长回文串划分
- 516. Longest Palindromic Subsequence 最长回文串子序列个数
- 139. Word Break
- 1524. Number of Sub-arrays With Odd Sum
- 403. Frog Jump
- 1423. Maximum Points You Can Obtain from Cards
- 1143. Longest Common Subsequence (经典,模板题)
- 718. Maximum Length of Repeated Subarray (与上题相似)
- 1312. Minimum Insertion Steps to Make a String Palindrome (记忆化递归, DP数组)
- 1155. Number of Dice Rolls With Target Sum (记忆化递归, DP数组)
- 1679. Max Number of K-Sum Pairs (HashMap)
- 96. Unique Binary Search Tree
- 95. Unique Binary Search Trees II
- 98. Validate a BST
- 99. Recover Binary Search Tree (Hard)
- 100. Same Tree (easy)
- 101. Symmetric Tree (easy)
- 110. Balanced Binary Tree
- 111. Minimum Depth of Binary Tree
- 105. Construct Binary Tree from Preorder and Inorder Traversal
- 108. Convert Sorted Array to Binary Search Tree (Easy)
- 538. Convert BST to Greater Tree
- 1038. Binary Search Tree to Greater Sum Tree (Same as 538)
- 107. 层序遍历
- 112. Path Sum
- 113. Path Sum II
- 116. Populating Next Right Pointers in Each Node
- 437. Path Sum III (easy)
- 124. Binary Tree Maximum Path Sum
- 306. Find Leaves of Binary Tree
- 701. Insert into a BST
- 572. Subtree of Another Tree
- 510. In-order Successor in BST II
- 449. Serialize and Deserialize BST (序列化:Node->String 和反序列化: String->Node)
- 236. Lowest Common Ancestor of a Binary Tree (经典, LCA 公共祖先问题)
- 1302. Deepest Leaves Sum
- 19. Remove Nth Node From End of List
- 24. Swap Nodes in Pair
- 141. Linked List Cycle
- 147. Insertion Sort List
- 160. Intersection of Two Linked Lists
- 109. Convert Sorted List to BST
- 206. Reverse Linked List (经典 每日一题)
- 25. Reverse Node in k-Group (经典 Hard)
- 92. Reverse Linked List II (经典)
- 328. Odd Even Linked List
- 82. Remove Duplicates from Sorted List II
- 79. Word Search
- 130. Surrounded Regions
- 200. Numbers of Islands (三种方法, 经典)
- 694. Number of Distinct Islands
- 695. Max Area of Island
- 547. Friend Circles
- 733. Flood Fill (经典)
- 967. Numbers With Same Consecutive Differences
- 980. Unique Paths III (Hard)
- 934. Shortest Bridge (BFS + DFS)
- 417. Pacific Atlantic Water Flow (大平洋大西洋水流, 经典模板题)
- 207. Course Schedule (经典)
- 210. Course Schedule II (经典)
- 934. Shortest Bridge (BFS + DFS)
- 994. Rotting Oranges
- 417. Pacific Atlantic Water Flow (大平洋大西洋水流, 经典模板题)
- 207. Course Schedule (经典)
- 210. Course Schedule II (经典)
- 399. Evaluate Division (Graph + BFS)
- 269. Alien Dictionary (Graph + BFS)
- 1192. Critical Connections in a Network (Hard)
- 277. Find the Celebrity
- 133. Clone Graph
- 863. All Nodes Distance K in Binary Tree
- 1334. Find the City With the Smallest Number of Neighbors at a Threshold Distance (Floyd-warshall 最短路径)
- 684. Redundant Connection (DFS, 并查集Union-Find)
- 162. Find Peak Element
- 4. Median of Two Sorted Arrays (Hard)
- 729. My Calendar I
- 33. Search in Rotated Sorted Array
- 34. Find First and Last Position of Element in Sorted Array
- 74. Search a 2D Matrix
- 153. Find Minimum in Rotated Sorted Array
- 209. Minimum Size Subarray Sum
- 230. Kth Smallest Element in a BST
- 240. Search a 2D Matrix II
- 270. Closest Binary Search Tree Value
- 287. Find the Duplicate Number
- 300. Longest Increasing Subsequence
- 315. Count of Smaller Numbers After Self
- 374. Guess Number Higher or Lower
- 410. Split Array Largest Sum (经典Hard, 二分+贪心)
- 875. Koko Eating Bananas
- 1283. Find the Smallest Divisor Given a Threshold
- 1337. The K Weakest Rows in a Matrix
- 1351. Count Negative Numbers in a Sorted Matrix
- 3. Longest Substring Without Repeating Characters
- 340. Longest Substring with At Most K Distinct Characters
- 76. Minimum Window Substring
- 30. Substring with Concatenation of All Words
- 模板题:String Anagrams (hard)
- 模板题:Permutation in a String (hard)
- 模板题: Merge Intervals (合并区间)
- 模板题: Insert Interval (插入区间)
- 模板题: Intervals Intersection (查找交集)
- 模板题: Conflicting Appointments (冲突区间)
- 模板题: Minimum Meeting Rooms (最少的会议室)
- Maximum CPU Load
- Employee Free Time (Hard)
- 729. My Calendar I
- 435. Non-overlapping Intervals (Greedy Method)
- 1272. Remove Interval
- 17. Letter Combinations of a Phone Number
- 22. Generate Parentheses
- 51. N皇后问题
- 46. Permutation
- 47. Permutations II
- 216. Combination Sum III
- 1718. Construct the Lexicographically Largest Valid Sequence (回溯, 暴力搜索)
- 84. Largest Rectangle in Histogram 直方图最大面积
- 232. Implement Queue using Stacks 利用栈实现队列
- 402. Remove K Digits
- 946. Validate Stack Sequences
- 71. Simplify Path
- 739. Daily Temperatures
- 973. K Closest Points to Origin (Medium)
- 378. Kth Smallest Element in a Sorted Matrix
- 295. Find Median from Data Stream (Hard)
- 146. LRU Cache (每日一题)
- 380. Insert Delete GetRandom O(1) (每日一题)
- 208. Implement Trie (Prefix Tree)
- 212. Word Search II
- 211. Add and Search Word - Data structure design
- 1286. Iterator for Combination (Google)
- 1032. Stream of Characters (Use Trie)
- 362. Design Hit Counter
- 41. First Missing Positive
- 238. Product of Array Except Self
- 179. Largest Number
- 498. Diagonal Traverse
- 334. Increasing Triplet Subsequence
- 442. Find All Duplicates in an Array
- 406. Queue Reconstruction by Height
- 624. Maximum Distance in Arrays
- 910. Smallest Range II
- 243. Shortest Word Distance
- 153. Find Minimum in Rotated Sorted Array (无重复元素)
- 154. Find Minimum in Rotated Sorted Array II (有重复元素)
- 1413. Minimum Value to Get Positive Step by Step Sum
- 10. Regular Expression Matching 字符匹配
- 32. Longest Valid Parentheses (经典)
- 38. Count and Say
- 44. Wildcard Matching 万卡匹配
- 97. Interleaving String (hard)
- 929. Unique Email Addresses
- 1041. Robot Bounded In Circle
- 763. Partition Labels
- 1505. Minimum Possible Integer After at Most K Adjacent Swaps On Digits
- 1291. Sequential Digits
- 468. Validate IP Address
- 556. Next Greater Element III
- 5. Longest Palindromic Substring (经典)
- 131. Palindrome Partitioning
- 214. Shortest Palindrome (Hard)
- 234. Palindrome Linked List (Easy)
- 266. Palindrome Permutation (Easy)
- 336.Palindrome Pairs (Hard, Amazon)
- 409. Longest Palindrome
- 516. Longest Palindromic Subsequence
- 647. Palindromic Substrings
- 1312. Minimum Insertion Steps to Make a String Palindrome (记忆化递归, DP数组)
- 680. Valid Palindrome II (Easy)