对自己做过的LeetCode及整理的解法进行整理,便于后续复习查看。实时更新。
# | Title | Solution | Difficulty | Related Topics |
---|---|---|---|---|
1 | Two Sum 两数之和 | Two Sum 两数之和 | Easy | Array,HashTable |
2 | Add Two Numbers 两数相加 | Add Two Numbers 两数相加 | Medium | Linked List,Math |
3 | Longest Substring Without Repeating Characters 无重复字符的最长子串 | Longest Substring Without Repeating Characters 无重复字符的最长子串 | Medium | Hash Table,Two Pointers,String,Sliding Window |
5 | Longest Palindromic Substring 最长回文子串 | Longest Palindromic Substring 最长回文子串 | Medium | String,Dynamic Programming |
6 | ZigZag Conversion Z字形变换 | ZigZag Conversion Z字形变换 | Medium | String |
7 | Reverse Integer 颠倒整数 | Reverse Integer 颠倒整数 | Easy | Math |
9 | Palindrome Number 回文数 | Palindrome Number 回文数 | Easy | Math |
11 | Container With Most Water 盛最多水的容器 | Container With Most Water 盛最多水的容器 | Medium | Array,Two Pointers |
12 | Integer to Roman 整数转罗马数字 | Integer to Roman 整数转罗马数字 | Medium | Math,String |
13 | Roman to Integer 罗马数字转整数 | Roman to Integer 罗马数字转整数 | Easy | Math,String |
14 | Longest Common Prefix 最长公共前缀 | Longest Common Prefix 最长公共前缀 | Easy | String |
15 | 3Sum 三数之和 | 3Sum 三数之和 | Medium | Array,Two Pointers |
16 | 3Sum Closest 最接近的三数之和 | 3Sum Closest 最接近的三数之和 | Medium | Array,Two Pointers |
17 | Letter Combinations of a Phone Number 电话号码的字母组合 | Letter Combinations of a Phone Number 电话号码的字母组合 | Medium | String,Backtracking |
18 | 4Sum 四数之和 | 4Sum 四数之和 | Medium | Array,Hash Table,Two Pointers |
19 | Remove Nth Node From End of List 删除链表的倒数第n个节点 | Remove Nth Node From End of List 删除链表的倒数第n个节点 | Medium | Linked List,Two Pointers |
20 | Valid Parentheses 有效的括号 | Valid Parentheses 有效的括号 | Easy | String,Stack |
21 | Merge Two Sorted Lists 合并两个有序链表 | Merge Two Sorted Lists 合并两个有序链表 | Easy | Linked List |
22 | Generate Parentheses 括号生成 | Generate Parentheses 括号生成 | Medium | String,Backtracking |
24 | Swap Nodes in Pairs 两两交换链表中的节点 | Swap Nodes in Pairs 两两交换链表中的节点 | Medium | Linked List |
26 | Remove Duplicates from Sorted Array 删除排序数组中的重复项 | Remove Duplicates from Sorted Array 删除排序数组中的重复项 | Easy | Array,Two Pointers |
27 | Remove Element 移除元素 | Remove Element 移除元素 | Easy | Array,Two Pointer |
28 | Implement strStr() 实现strStr() | Implement strStr() 实现strStr() | Easy | Two Pointers,String |
29 | Divide Two Integers 两数相除 | Divide Two Integers 两数相除 | Medium | Math,Binary Search |
31 | Next Permutation 下一个排列 | Next Permutation 下一个排列 | Medium | Array |
33 | Search in Rotated Sorted Array 搜索旋转排序数组 | Search in Rotated Sorted Array 搜索旋转排序数组 | Medium | Array,Binary Search |
34 | Find First and Last Position of Element in Sorted Array 在排序数组中查找元素的第一个和最后一个位置 | Find First and Last Position of Element in Sorted Array 在排序数组中查找元素的第一个和最后一个位置 | Medium | Array,Binary Search |
35 | Search Insert Position 搜索插入位置 | Search Insert Position 搜索插入位置 | Easy | Array,Binary Search |
36 | Valid Sudoku 有效的数独 | Valid Sudoku 有效的数独 | Medium | Hash Table |
38 | Count and Say 报数 | Count and Say 报数 | Easy | String |
39 | Combination Sum 组合总和 | Combination Sum 组合总和 | Medium | Array,Backtracking |
40 | Combination Sum II 组合总和II | Combination Sum II 组合总和II | Medium | Array,Backtracking |
43 | Multiply Strings 字符串相乘 | Multiply Strings 字符串相乘 | Medium | Math,String |
46 | Permutations 全排序 | Permutations 全排序 | Medium | Backtracking |
47 | Permutations II 全排列II | Permutations II 全排列II | Medium | Backtracking |
48 | Rotate Image 旋转图像 | Rotate Image 旋转图像 | Medium | Array |
49 | Group Anagrams 字母异位词分组 | Group Anagrams 字母异位词分组 | Medium | Hash Table,String |
50 | Pow(x, n) Pow(x, n) | Pow(x, n) Pow(x, n) | Medium | Math,Binary Search |
53 | Maximum Subarray 最大子序和 | Maximum Subarray 最大子序和 | Easy | Array,Divide and Conquer,Dynamic Programming |
54 | Spiral Matrix 螺旋矩阵 | Spiral Matrix 螺旋矩阵 | Medium | Array |
55 | Jump Game 跳跃游戏 | Jump Game 跳跃游戏 | Medium | Array,Greedy |
56 | Merge Intervals 合并区间 | Merge Intervals 合并区间 | Medium | Array,Sort |
58 | Length of Last Word 最后一个单词的长度 | Length of Last Word 最后一个单词的长度 | Easy | String |
59 | Spiral Matrix II 螺旋矩阵II | Spiral Matrix II 螺旋矩阵II | Medium | Array |
60 | Permutation Sequence 第k个排列 | Permutation Sequence 第k个排列 | Medium | Math,Backtracking |
61 | Rotate List 旋转链表 | Rotate List 旋转链表 | Medium | Linked List,Two Pointers |
62/63 | Unique Paths 不同路径I/II | Unique Paths 不同路径I/II | Medium | Array,Dynamic Programming |
64 | Minimum Path Sum 最小路径和 | Minimum Path Sum 最小路径和 | Medium | Array,Dynamic Programming |
66 | Plus One 加一 | Plus One 加一 | Easy | Array |
67 | Add Binary 二进制求和 | Add Binary 二进制求和 | Easy | Math,String |
69 | Sqrt(x) x的平方根 | Sqrt(x) x的平方根 | Easy | Math,Binary Search |
70 | Climbing Stairs 爬楼梯 | Climbing Stairs 爬楼梯 | Easy | Dynamic Programming |
73 | Set Matrix Zeroes 矩阵置零 | Set Matrix Zeroes 矩阵置零 | Medium | Array |
74 | Search a 2D Matrix 搜索二维矩阵 | Search a 2D Matrix 搜索二维矩阵 | Medium | Array,Binary Search |
75 | Sort Colors 颜色分类 | Sort Colors 颜色分类 | Medium | Array,Two Pointers,Sort |
77 | Combinations 组合 | Combinations 组合 | Medium | Backtracking |
78 | Subsets 子集 | Subsets 子集 | Medium | Array,Backtracking,Bit Manipulation |
79 | Word Search 单次搜索 | Word Search 单次搜索 | Medium | Array,Backtracking |
80 | Remove Duplicates from Sorted Array II 删除排序数组中的重复项II | Remove Duplicates from Sorted Array II 删除排序数组中的重复项II | Medium | Array,Two Pointers |
81 | Search in Rotated Sorted Array II 搜索旋转排序数组II | Search in Rotated Sorted Array II 搜索旋转排序数组II | Medium | Array,Binary Search |
82 | Remove Duplicates from Sorted List II 删除排序链表中的重复元素 | Remove Duplicates from Sorted List II 删除排序链表中的重复元素 | Medium | Linked List |
83 | Remove Duplicates from Sorted List 删除有序链表中的重复元素 | Remove Duplicates from Sorted List 删除有序链表中的重复元素 | Easy | Linked List |
86 | Partition List 分隔链表 | Partition List 分隔链表 | Medium | LinkedList,Two Pointers |
88 | Merge Sorted Array 合并两个有序数组 | Merge Sorted Array 合并两个有序数组 | Easy | Array,Two Pointers |
90 | Subsets II 子集II | Subsets II 子集II | Medium | Array,Backtracking |
91 | Decode Ways 解码方式 | Decode Ways 解码方式 | Medium | String,Dynamic Programming |
92 | Reverse Linked List II 反转链表II | Reverse Linked List II 反转链表II | Medium | Linked List |
93 | Restore IP Addresses 复原IP地址 | Restore IP Addresses 复原IP地址 | Medium | String,Backtracking |
94 | Binary Tree Inorder Traversal 二叉树的中序遍历 | Binary Tree Inorder Traversal 二叉树的中序遍历 | Medium | Hash Table,Stack,Tree |
95 | Unique Binary Search Trees II 不同的二叉搜索树II | Unique Binary Search Trees II 不同的二叉搜索树II | Medium | Dynamic Programming,Tree |
96 | Unique Binary Search Trees 不同的二叉搜索树 | Unique Binary Search Trees 不同的二叉搜索树 | Medium | Dynamic Programming,Tree |
98 | Validate Binary Search Tree 验证二叉搜索树 | Validate Binary Search Tree 验证二叉搜索树 | Medium | Tree,Depth-first Search |
100 | Same Tree 判断两棵二叉树是否相等 | Same Tree 判断两棵二叉树是否相等 | Easy | Tree,Depth-first Search |
101 | Symmetric Tree 对称二叉树 | Symmetric Tree 对称二叉树 | Easy | Tree,Depth-first Search,Breadth-first Search |
102 | Binary Tree Level Order Traversal 二叉树的层级遍历 | Binary Tree Level Order Traversal 二叉树的层级遍历 | Medium | Tree,Breadth-first Search |
103 | Binary Tree Zigzag Level Order Traversal 二叉树Z字形层级遍历 | Binary Tree Zigzag Level Order Traversal 二叉树Z字形层级遍历 | Medium | Stack,Tree,Breadth-first Search |
104 | Maximum Depth of Binary Tree二叉树的最大深度 | Maximum Depth of Binary Tree二叉树的最大深度 | Easy | Tree,Depth-first Search |
105 | Construct Binary Tree from Preorder and Inorder Traversal 根据前序、中序遍历序列构建二叉树 | Construct Binary Tree from Preorder and Inorder Traversal 根据前序、中序遍历序列构建二叉树 | Medium | Array,Tree,Depth-fist Search |
106 | Construct Binary Tree from Inorder and Postorder Traversal 根据中序、后序遍历序列构建二叉树 | Construct Binary Tree from Inorder and Postorder Traversal 根据中序、后序遍历序列构建二叉树 | Medium | Array,Tree,Depth-fist Search |
107 | Binary Tree Level Order Traversal II 二叉树的层次遍历 | Binary Tree Level Order Traversal II 二叉树的层次遍历 | Easy | Tree,Breadth-first Search |
108 | Convert Sorted Array to Binary Search Tree 将有序数组转换为二叉搜索树 | Convert Sorted Array to Binary Search Tree 将有序数组转换为二叉搜索树 | Easy | Tree,Depth-first Search |
109 | Convert Sorted List to Binary Search Tree 有序链表转换二叉搜索树 | Convert Sorted List to Binary Search Tree 有序链表转换二叉搜索树 | Medium | Linked List,Depth-first Search |
110 | Balanced Binary Tree 判断是否为平衡二叉树 | Balanced Binary Tree 判断是否为平衡二叉树 | Easy | Tree,Depth-first Search |
111 | Minimum Depth of Binary Tree 二叉树的最小深度 | Minimum Depth of Binary Tree 二叉树的最小深度 | Easy | Tree,Depth-first Tree,Breadth-first Search |
112 | Path Sum 寻找二叉树路径和 | Path Sum 寻找二叉树路径和 | Easy | Tree,Depth-first Tree |
113 | Path Sum II 寻找二叉树路径总和II | Path Sum II 寻找二叉树路径总和II | Medium | Tree,Depth-first Tree |
114 | Flatten Binary Tree to Linked List 二叉树展开为链表 | Flatten Binary Tree to Linked List 二叉树展开为链表 | Medium | Tree,Depth-first Tree |
116 | Populating Next Right Pointers in Each Node 填充每个节点的下一个右侧节点指针 | Populating Next Right Pointers in Each Node 填充每个节点的下一个右侧节点指针 | Medium | Tree,Depth-first Tree |
117 | Populating Next Right Pointers in Each Node II 填充每个节点的下一个右侧节点指针II | Populating Next Right Pointers in Each Node II 填充每个节点的下一个右侧节点指针II | Medium | Tree,Depth-first Tree |
118/119 | Pascal’s Triangle 杨辉三角 | Pascal’s Triangle 杨辉三角 | Easy | Array |
120 | Triangle 三角形最小路径和 | Triangle 三角形最小路径和 | Medium | Array,Dynamic Programming |
121/122 | Best Time to Buy and Sell Stock 购买股票的最佳时机 | Best Time to Buy and Sell Stock 购买股票的最佳时机 | Easy | Array,Dynamic Programming |
125 | Valid Palindrome 验证回文串 | Valid Palindrome 验证回文串 | Easy | Two Pointers,String |
127 | Word Ladder 单词接龙 | Word Ladder 单词接龙 | Medium | Breadth-first Search |
129 | Sum Root to Leaf Numbers 根到叶子节点数字之和 | Sum Root to Leaf Numbers 根到叶子节点数字之和 | Medium | Tree,Depth-first Search |
130 | Surrounded Regions 被围绕的区域 | Surrounded Regions 被围绕的区域 | Medium | Depth-first Search,Breadth-first Search,Union Find |
131 | Palindrome Partitioning 分割回文串 | Palindrome Partitioning 分割回文串 | Medium | Backtracking |
133 | 添Clone Graph 克隆图 | Clone Graph 克隆图 | Medium | Depth-first Search,Breadth-first Search,Graph |
134 | Gas Station 加油站 | Gas Station 加油站 | Medium | Greedy |
136 | Single Number 只出现一次的数字 | Single Number 只出现一次的数字 | Easy | Hash Table,Bit Manipulation |
137 | Single Number II 只出现一次的数字 | Single Number II 只出现一次的数字 | Medium | Bit Manipulation |
141 | Linked List Cycle 环形链表 | Linked List Cycle 环形链表 | Easy | Linked List,Two Pointers |
155 | Min Stack 最小栈 | Min Stack 最小栈 | Easy | Stack,Design |
160 | Intersection of Two Linked Lists 相交链表 | Intersection of Two Linked Lists 相交链表 | Easy | Linked List |
167 | Two Sum II 两数之和 II | Two Sum II 两数之和 II | Easy | Array,Two Pointers,Binary Search |
168 | Excel Sheet Column Title Excel表列名称 | Excel Sheet Column Title Excel表列名称 | Easy | Math |
169 | Majority Element 求众数 | Majority Element 求众数 | Easy | Array,Divide and Conquer,Bit Manipulation |
171 | Excel Sheet Column Number Excel表列序号 | Excel Sheet Column Number Excel表列序号 | Easy | Math |
172 | Factorial Trailing Zeroes 阶乘后的零 | Factorial Trailing Zeroes 阶乘后的零 | Easy | Math |
175 | Combine Two Tables 组合两个表 | Combine Two Tables 组合两个表 | Easy | SQL |
176 | Second Highest Salary 第二高薪水 | Second Highest Salary 第二高薪水 | Easy | SQL |
181 | Employees Earning More Than Their Managers 超过经理收入的员工 | Employees Earning More Than Their Managers 超过经理收入的员工 | Easy | SQL |
182 | Duplicate Emails 查找重复的电子邮件 | Duplicate Emails 查找重复的电子邮件 | Easy | SQL |
183 | Customers Who Never Order 从不订购的客户 | Customers Who Never Order 从不订购的客户 | Easy | SQL |
189 | Rotate Array 旋转数组 | Rotate Array 旋转数组 | Easy | Array |
190 | Reverse Bits 颠倒二进制位 | Reverse Bits 颠倒二进制位 | Easy | Bit Manipulation |
191 | Number of 1 Bits 位1的个数 | Number of 1 Bits 位1的个数 | Easy | Bit Manipulation |
196 | Delete Duplicate Emails 删除重复的电子邮件 | Delete Duplicate Emails 删除重复的电子邮件 | Easy | SQL |
197 | Rising Temperature 上升的温度 | Rising Temperature 上升的温度 | Easy | SQL |
198 | House Robber 打家劫舍 | House Robber 打家劫舍 | Easy | Dynamic Programming |
202 | Happy Number 快乐数 | Happy Number 快乐数 | Easy | Hash Table,Math |
203 | Remove Linked List Elements 移除链表元素 | Remove Linked List Elements 移除链表元素 | Easy | Linked List |
204 | Count Primes 计数质数 | Count Primes 计数质数 | Easy | Hash Table,Math |
205 | Isomorphic Strings 同构字符串 | Isomorphic Strings 同构字符串 | Easy | Hash Table |
206 | Reverse Linked List 反转链表 | Reverse Linked List 反转链表 | Easy | Linked List |
217 | Contains Duplicate 存在重复元素 | Contains Duplicate 存在重复元素 | Easy | Hash Table,Array |
219 | Contains Duplicate II 存在重复元素 II | Contains Duplicate II 存在重复元素 II | Easy | Array,Hash Table |
225 | Implement Stack using Queues 用队列实现栈 | Implement Stack using Queues 用队列实现栈 | Easy | Stack,Design |
226 | Invert Binary Tree 翻转二叉树 | Invert Binary Tree 翻转二叉树 | Easy | Tree |
231 | Power of Two 判断是否为2的幂 | Power of Two 判断是否为2的幂 | Easy | Math,Bit Manipulation |
232 | Implement Queue using Stacks 用栈实现队列 | Implement Queue using Stacks 用栈实现队列 | Easy | Stack,Design |
234 | Palindrome Linked List 回文链表 | Palindrome Linked List 回文链表 | Easy | Linked List,Two Pointers |
235 | Lowest Common Ancestor of a Binary Search Tree 二叉搜索树的最近公共祖先 | Lowest Common Ancestor of a Binary Search Tree 二叉搜索树的最近公共祖先 | Easy | Tree |
237 | Delete Node in a Linked List 删除链表中的节点 | Delete Node in a Linked List 删除链表中的节点 | Easy | Linked List |
242 | Valid Anagram 有效的字母异位词 | Valid Anagram 有效的字母异位词 | Easy | Hash Table,Sort |
257 | Binary Tree Paths 二叉树的所有路径 | Binary Tree Paths 二叉树的所有路径 | Easy | Tree,Depth-first Search |
258 | Add Digits 各位相加 | Add Digits 各位相加 | Easy | Math |
263 | Ugly Number 丑数 | Ugly Number 丑数 | Easy | Math |
268 | Missing Number 缺失数组 | Missing Number 缺失数组 | Easy | Array,Math,Bit Manipulation |
278 | First Bad Version 第一个错误的版本 | First Bad Version 第一个错误的版本 | Easy | Binary Search |
283 | Move Zeroes 移动零 | Move Zeroes 移动零 | Easy | Array,Two Pointers |
290 | Word Pattern 单词模式 | Word Pattern 单词模式 | Easy | Hash Table |
292 | Nim Game Nim游戏 | Nim Game Nim游戏 | Easy | Brainteaser,Minimax |
414 | Third Maximum Number 第三大的数 | Third Maximum Number 第三大的数 | Easy | Array |