Skip to content

Commit 478ff99

Browse files
committed
更新题解列表
1 parent 3af2fcd commit 478ff99

File tree

825 files changed

+3305
-6
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

825 files changed

+3305
-6
lines changed

Solutions/0001. 两数之和.md

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
- 标签:数组、哈希表
44
- 难度:简单
55

6+
## 题目链接
7+
8+
- [0001. 两数之和 - 力扣](https://leetcode.cn/problems/two-sum/)
9+
610
## 题目大意
711

812
**描述**:给定一个整数数组 $nums$ 和一个整数目标值 $target$。

Solutions/0002. 两数相加.md

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
- 标签:递归、链表、数学
44
- 难度:中等
55

6+
## 题目链接
7+
8+
- [0002. 两数相加 - 力扣](https://leetcode.cn/problems/add-two-numbers/)
9+
610
## 题目大意
711

812
**描述**:给定两个非空的链表 `l1``l2`。分别用来表示两个非负整数,每位数字都是按照逆序的方式存储的,每个节点存储一位数字。

Solutions/0003. 无重复字符的最长子串.md

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
- 标签:哈希表、字符串、滑动窗口
44
- 难度:中等
55

6+
## 题目链接
7+
8+
- [0003. 无重复字符的最长子串 - 力扣](https://leetcode.cn/problems/longest-substring-without-repeating-characters/)
9+
610
## 题目大意
711

812
**描述**:给定一个字符串 $s$。

Solutions/0004. 寻找两个正序数组的中位数.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
- 标签:数组、二分查找、分治
44
- 难度:困难
55

6+
## 题目链接
7+
8+
- [0004. 寻找两个正序数组的中位数 - 力扣](https://leetcode.cn/problems/median-of-two-sorted-arrays/)
9+
610
## 题目大意
711

812
**描述**:给定两个正序(从小到大排序)数组 $nums1$、$nums2$。
@@ -120,5 +124,5 @@ class Solution:
120124

121125
### 思路 1:复杂度分析
122126

123-
- **时间复杂度**:$O(\log_2 (m + n))$ 。
127+
- **时间复杂度**:$O(\log (m + n))$ 。
124128
- **空间复杂度**:$O(1)$。

Solutions/0005. 最长回文子串.md

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
- 标签:字符串、动态规划
44
- 难度:中等
55

6+
## 题目链接
7+
8+
- [0005. 最长回文子串 - 力扣](https://leetcode.cn/problems/longest-palindromic-substring/)
9+
610
## 题目大意
711

812
**描述**:给定一个字符串 $s$。

Solutions/0007. 整数反转.md

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
- 标签:数学
44
- 难度:中等
55

6+
## 题目链接
7+
8+
- [0007. 整数反转 - 力扣](https://leetcode.cn/problems/reverse-integer/)
9+
610
## 题目大意
711

812
给定一个 32 位有符号整数 x,将 x 进行反转。

Solutions/0008. 字符串转换整数 (atoi).md

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
- 标签:字符串
44
- 难度:中等
55

6+
## 题目链接
7+
8+
- [0008. 字符串转换整数 (atoi) - 力扣](https://leetcode.cn/problems/string-to-integer-atoi/)
9+
610
## 题目大意
711

812
**描述**:给定一个字符串 `s`

Solutions/0009. 回文数.md

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
- 标签:数学
44
- 难度:简单
55

6+
## 题目链接
7+
8+
- [0009. 回文数 - 力扣](https://leetcode.cn/problems/palindrome-number/)
9+
610
## 题目大意
711

812
给定整数 x,判断 x 是否是回文数。要求不能用整数转为字符串的方式来解决这个问题。

Solutions/0010. 正则表达式匹配.md

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
- 标签:递归、字符串、动态规划
44
- 难度:困难
55

6+
## 题目链接
7+
8+
- [0010. 正则表达式匹配 - 力扣](https://leetcode.cn/problems/regular-expression-matching/)
9+
610
## 题目大意
711

812
**描述**:给定一个字符串 `s` 和一个字符模式串 `p`

Solutions/0011. 盛最多水的容器.md

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
- 标签:贪心、数组、双指针
44
- 难度:中等
55

6+
## 题目链接
7+
8+
- [0011. 盛最多水的容器 - 力扣](https://leetcode.cn/problems/container-with-most-water/)
9+
610
## 题目大意
711

812
**描述**:给定 $n$ 个非负整数 $a_1,a_2, ...,a_n$,每个数代表坐标中的一个点 $(i, a_i)$。在坐标内画 $n$ 条垂直线,垂直线 $i$ 的两个端点分别为 $(i, a_i)$ 和 $(i, 0)$。

Solutions/0012. 整数转罗马数字.md

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
- 标签:哈希表、数学、字符串
44
- 难度:中等
55

6+
## 题目链接
7+
8+
- [0012. 整数转罗马数字 - 力扣](https://leetcode.cn/problems/integer-to-roman/)
9+
610
## 题目大意
711

812
给定一个整数,将其转换为罗马数字。

Solutions/0013. 罗马数字转整数.md

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
- 标签:哈希表、数学、字符串
44
- 难度:简单
55

6+
## 题目链接
7+
8+
- [0013. 罗马数字转整数 - 力扣](https://leetcode.cn/problems/roman-to-integer/)
9+
610
## 题目大意
711

812
给定一个罗马数字对应的字符串,将其转换为整数。

Solutions/0014. 最长公共前缀.md

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
- 标签:字典树、字符串
44
- 难度:简单
55

6+
## 题目链接
7+
8+
- [0014. 最长公共前缀 - 力扣](https://leetcode.cn/problems/longest-common-prefix/)
9+
610
## 题目大意
711

812
**描述**:给定一个字符串数组 `strs`

Solutions/0015. 三数之和.md

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
- 标签:数组、双指针、排序
44
- 难度:中等
55

6+
## 题目链接
7+
8+
- [0015. 三数之和 - 力扣](https://leetcode.cn/problems/3sum/)
9+
610
## 题目大意
711

812
**描述**:给定一个整数数组 $nums$。

Solutions/0016. 最接近的三数之和.md

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
- 标签:数组、双指针、排序
44
- 难度:中等
55

6+
## 题目链接
7+
8+
- [0016. 最接近的三数之和 - 力扣](https://leetcode.cn/problems/3sum-closest/)
9+
610
## 题目大意
711

812
给你一个整数数组 `nums` 和 一个目标值 `target`

Solutions/0017. 电话号码的字母组合.md

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
- 标签:哈希表、字符串、回溯
44
- 难度:中等
55

6+
## 题目链接
7+
8+
- [0017. 电话号码的字母组合 - 力扣](https://leetcode.cn/problems/letter-combinations-of-a-phone-number/)
9+
610
## 题目大意
711

812
**描述**:给定一个只包含数字 2~9 的字符串 `digits`。给出数字到字母的映射如下(与电话按键相同)。注意 $1$ 不对应任何字母。

Solutions/0018. 四数之和.md

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
- 标签:数组、双指针、排序
44
- 难度:中等
55

6+
## 题目链接
7+
8+
- [0018. 四数之和 - 力扣](https://leetcode.cn/problems/4sum/)
9+
610
## 题目大意
711

812
**描述**:给定一个整数数组 $nums$ 和一个目标值 $target$。

Solutions/0019. 删除链表的倒数第 N 个结点.md

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
- 标签:链表、双指针
44
- 难度:中等
55

6+
## 题目链接
7+
8+
- [0019. 删除链表的倒数第 N 个结点 - 力扣](https://leetcode.cn/problems/remove-nth-node-from-end-of-list/)
9+
610
## 题目大意
711

812
**描述**:给定一个链表的头节点 `head`

Solutions/0020. 有效的括号.md

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
- 标签:栈、字符串
44
- 难度:简单
55

6+
## 题目链接
7+
8+
- [0020. 有效的括号 - 力扣](https://leetcode.cn/problems/valid-parentheses/)
9+
610
## 题目大意
711

812
**描述**:给定一个只包括 `'('``')'``'{'``'}'``'['``']'` 的字符串 `s`

Solutions/0021. 合并两个有序链表.md

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
- 标签:递归、链表
44
- 难度:简单
55

6+
## 题目链接
7+
8+
- [0021. 合并两个有序链表 - 力扣](https://leetcode.cn/problems/merge-two-sorted-lists/)
9+
610
## 题目大意
711

812
**描述**:给定两个升序链表的头节点 `list1``list2`

Solutions/0022. 括号生成.md

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
- 标签:字符串、回溯算法
44
- 难度:中等
55

6+
## 题目链接
7+
8+
- [0022. 括号生成 - 力扣](https://leetcode.cn/problems/generate-parentheses/)
9+
610
## 题目大意
711

812
**描述**:给定一个整数 $n$,代表生成括号的对数。

Solutions/0023. 合并 K 个升序链表.md

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
- 标签:链表、分治、堆(优先队列)、归并排序
44
- 难度:困难
55

6+
## 题目链接
7+
8+
- [0023. 合并 K 个升序链表 - 力扣](https://leetcode.cn/problems/merge-k-sorted-lists/)
9+
610
## 题目大意
711

812
**描述**:给定一个链表数组,每个链表都已经按照升序排列。

Solutions/0024. 两两交换链表中的节点.md

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
- 标签:递归、链表
44
- 难度:中等
55

6+
## 题目链接
7+
8+
- [0024. 两两交换链表中的节点 - 力扣](https://leetcode.cn/problems/swap-nodes-in-pairs/)
9+
610
## 题目大意
711

812
**描述**:给定一个链表的头节点 `head`

Solutions/0025. K 个一组翻转链表.md

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
- 标签:递归、链表
44
- 难度:困难
55

6+
## 题目链接
7+
8+
- [0025. K 个一组翻转链表 - 力扣](https://leetcode.cn/problems/reverse-nodes-in-k-group/)
9+
610
## 题目大意
711

812
**描述**:给你链表的头节点 `head` ,再给定一个正整数 `k``k` 的值小于或等于链表的长度。

Solutions/0026. 删除有序数组中的重复项.md

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
- 标签:数组、双指针
44
- 难度:简单
55

6+
## 题目链接
7+
8+
- [0026. 删除有序数组中的重复项 - 力扣](https://leetcode.cn/problems/remove-duplicates-from-sorted-array/)
9+
610
## 题目大意
711

812
**描述**:给定一个有序数组 `nums`

Solutions/0027. 移除元素.md

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
- 标签:数组、双指针
44
- 难度:简单
55

6+
## 题目链接
7+
8+
- [0027. 移除元素 - 力扣](https://leetcode.cn/problems/remove-element/)
9+
610
## 题目大意
711

812
**描述**:给定一个数组 $nums$,和一个值 $val$。

Solutions/0028. 找出字符串中第一个匹配项的下标.md

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
- 标签:双指针、字符串、字符串匹配
44
- 难度:中等
55

6+
## 题目链接
7+
8+
- [0028. 找出字符串中第一个匹配项的下标 - 力扣](https://leetcode.cn/problems/find-the-index-of-the-first-occurrence-in-a-string/)
9+
610
## 题目大意
711

812
**描述**:给定两个字符串 `haystack``needle`

Solutions/0029. 两数相除.md

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
- 标签:位运算、数学
44
- 难度:中等
55

6+
## 题目链接
7+
8+
- [0029. 两数相除 - 力扣](https://leetcode.cn/problems/divide-two-integers/)
9+
610
## 题目大意
711

812
给定两个整数,被除数 dividend 和除数 divisor。要求返回两数相除的商,并且不能使用乘法,除法和取余运算。取值范围在 $[-2^{31}, 2^{31}-1]$。如果结果溢出,则返回 $2^{31} - 1$。

Solutions/0032. 最长有效括号.md

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
- 标签:栈、字符串、动态规划
44
- 难度:困难
55

6+
## 题目链接
7+
8+
- [0032. 最长有效括号 - 力扣](https://leetcode.cn/problems/longest-valid-parentheses/)
9+
610
## 题目大意
711

812
**描述**:给定一个只包含 `'('``')'` 的字符串。

Solutions/0033. 搜索旋转排序数组.md

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
- 标签:数组、二分查找
44
- 难度:中等
55

6+
## 题目链接
7+
8+
- [0033. 搜索旋转排序数组 - 力扣](https://leetcode.cn/problems/search-in-rotated-sorted-array/)
9+
610
## 题目大意
711

812
**描述**:给定一个整数数组 $nums$,数组中值互不相同。给定的 $nums$ 是经过升序排列后的又进行了「旋转」操作的。再给定一个整数 $target$。

Solutions/0034. 在排序数组中查找元素的第一个和最后一个位置.md

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
- 标签:数组、二分查找
44
- 难度:中等
55

6+
## 题目链接
7+
8+
- [0034. 在排序数组中查找元素的第一个和最后一个位置 - 力扣](https://leetcode.cn/problems/find-first-and-last-position-of-element-in-sorted-array/)
9+
610
## 题目大意
711

812
**描述**:给你一个按照非递减顺序排列的整数数组 `nums`,和一个目标值 `target`

Solutions/0035. 搜索插入位置.md

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
- 标签:数组、二分查找
44
- 难度:简单
55

6+
## 题目链接
7+
8+
- [0035. 搜索插入位置 - 力扣](https://leetcode.cn/problems/search-insert-position/)
9+
610
## 题目大意
711

812
**描述**:给定一个排好序的数组 $nums$,以及一个目标值 $target$。

Solutions/0036. 有效的数独.md

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
- 标签:数组、哈希表、矩阵
44
- 难度:中等
55

6+
## 题目链接
7+
8+
- [0036. 有效的数独 - 力扣](https://leetcode.cn/problems/valid-sudoku/)
9+
610
## 题目大意
711

812
**描述**:给定一个数独,用 `9 * 9` 的二维字符数组 `board` 来表示,其中,未填入的空白用 "." 代替。

Solutions/0037. 解数独.md

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
- 标签:数组、哈希表、回溯、矩阵
44
- 难度:困难
55

6+
## 题目链接
7+
8+
- [0037. 解数独 - 力扣](https://leetcode.cn/problems/sudoku-solver/)
9+
610
## 题目大意
711

812
**描述**:给定一个二维的字符数组 $board$ 用来表示数独,其中数字 $1 \sim 9$ 表示该位置已经填入了数字,`.` 表示该位置还没有填入数字。

Solutions/0038. 外观数列.md

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
- 标签:字符串
44
- 难度:中等
55

6+
## 题目链接
7+
8+
- [0038. 外观数列 - 力扣](https://leetcode.cn/problems/count-and-say/)
9+
610
## 题目大意
711

812
给定一个正整数 n,$(1 \le n \le 30)$,要求输出外观数列的第 n 项。

0 commit comments

Comments
 (0)