Skip to content

Commit e6fbaed

Browse files
committed
update leetcode spider
1 parent cb2cfa9 commit e6fbaed

File tree

3,037 files changed

+302047
-60933
lines changed

Some content is hidden

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

3,037 files changed

+302047
-60933
lines changed

assets/output/0001.md

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
# [1. 两数之和](https://leetcode.com/problems/two-sum)
2+
3+
🟢 <font color=#15bd66>Easy</font>&emsp; 🔖&ensp; [`数组`](/leetcode/outline/tag/array.md) [`哈希表`](/leetcode/outline/tag/hash-table.md)&emsp; 🔗&ensp;[`LeetCode`](https://leetcode.com/problems/two-sum)
4+
5+
6+
## 题目
7+
8+
Given an array of integers `nums` and an integer `target`, return _indices of
9+
the two numbers such that they add up to`target`_.
10+
11+
You may assume that each input would have **_exactly_ one solution**, and you
12+
may not use the _same_ element twice.
13+
14+
You can return the answer in any order.
15+
16+
17+
18+
**Example 1:**
19+
20+
> Input: nums = [2,7,11,15], target = 9
21+
>
22+
> Output: [0,1]
23+
>
24+
> Explanation: Because nums[0] + nums[1] == 9, we return [0, 1].
25+
26+
**Example 2:**
27+
28+
> Input: nums = [3,2,4], target = 6
29+
>
30+
> Output: [1,2]
31+
32+
**Example 3:**
33+
34+
> Input: nums = [3,3], target = 6
35+
>
36+
> Output: [0,1]
37+
38+
**Constraints:**
39+
40+
* `2 <= nums.length <= 10^4`
41+
* `-10^9 <= nums[i] <= 10^9`
42+
* `-10^9 <= target <= 10^9`
43+
* **Only one valid answer exists.**
44+
45+
46+
47+
**Follow-up: **Can you come up with an algorithm that is less than `O(n2)`
48+
time complexity?
49+
50+
51+
## 题目大意
52+
53+
给定一个整数数组 `nums` 和一个整数目标值 `target`,请你在该数组中找出 **和为目标值** _`target`_ 的那 **两个**
54+
整数,并返回它们的数组下标。
55+
56+
你可以假设每种输入只会对应一个答案,并且你不能使用两次相同的元素。
57+
58+
你可以按任意顺序返回答案。
59+
60+
61+
62+
**示例 1:**
63+
64+
>
65+
>
66+
>
67+
>
68+
>
69+
> **输入:** nums = [2,7,11,15], target = 9
70+
>
71+
> **输出:**[0,1]
72+
>
73+
> **解释:** 因为 nums[0] + nums[1] == 9 ,返回 [0, 1]
74+
>
75+
>
76+
77+
**示例 2:**
78+
79+
>
80+
>
81+
>
82+
>
83+
>
84+
> **输入:** nums = [3,2,4], target = 6
85+
>
86+
> **输出:**[1,2]
87+
>
88+
>
89+
90+
**示例 3:**
91+
92+
>
93+
>
94+
>
95+
>
96+
>
97+
> **输入:** nums = [3,3], target = 6
98+
>
99+
> **输出:**[0,1]
100+
>
101+
>
102+
103+
104+
105+
**提示:**
106+
107+
* `2 <= nums.length <= 10^4`
108+
* `-10^9 <= nums[i] <= 10^9`
109+
* `-10^9 <= target <= 10^9`
110+
* **只会存在一个有效答案**
111+
112+
113+
114+
**进阶:** 你可以想出一个时间复杂度小于 `O(n2)` 的算法吗?
115+
116+
117+
## 解题思路
118+
119+
#### 复杂度分析
120+
121+
- **时间复杂度**`O()`
122+
- **空间复杂度**`O()`
123+
124+
## 代码
125+
126+
```javascript
127+
128+
```
129+
130+
## 相关题目
131+
132+
:::: md-demo 相关题目
133+
- [三数之和](https://leetcode.com/problems/3sum)
134+
- [四数之和](https://leetcode.com/problems/4sum)
135+
- [两数之和 II - 输入有序数组](https://leetcode.com/problems/two-sum-ii-input-array-is-sorted)
136+
- [两数之和 III - 数据结构设计](https://leetcode.com/problems/two-sum-iii-data-structure-design)
137+
- [和为 K 的子数组](https://leetcode.com/problems/subarray-sum-equals-k)
138+
- [两数之和 IV - 输入二叉搜索树](https://leetcode.com/problems/two-sum-iv-input-is-a-bst)
139+
- [小于 K 的两数之和](https://leetcode.com/problems/two-sum-less-than-k)
140+
- [K 和数对的最大数目](https://leetcode.com/problems/max-number-of-k-sum-pairs)
141+
- [大餐计数](https://leetcode.com/problems/count-good-meals)
142+
- [差的绝对值为 K 的数对数目](https://leetcode.com/problems/count-number-of-pairs-with-absolute-difference-k)
143+
- [连接后等于目标字符串的字符串对](https://leetcode.com/problems/number-of-pairs-of-strings-with-concatenation-equal-to-target)
144+
- [找出数组中的所有 K 近邻下标](https://leetcode.com/problems/find-all-k-distant-indices-in-an-array)
145+
- [第一个出现两次的字母](https://leetcode.com/problems/first-letter-to-appear-twice)
146+
- [优质数对的数目](https://leetcode.com/problems/number-of-excellent-pairs)
147+
- [等差三元组的数目](https://leetcode.com/problems/number-of-arithmetic-triplets)
148+
- [边积分最高的节点](https://leetcode.com/problems/node-with-highest-edge-score)
149+
- [检查相同字母间的距离](https://leetcode.com/problems/check-distances-between-same-letters)
150+
- [和相等的子数组](https://leetcode.com/problems/find-subarrays-with-equal-sum)
151+
- [与对应负数同时存在的最大正整数](https://leetcode.com/problems/largest-positive-integer-that-exists-with-its-negative)
152+
- [不同的平均值数目](https://leetcode.com/problems/number-of-distinct-averages)
153+
- [统计和小于目标的下标对数目](https://leetcode.com/problems/count-pairs-whose-sum-is-less-than-target)
154+
155+
::::

assets/output/0002.md

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
# [2. 两数相加](https://leetcode.com/problems/add-two-numbers)
2+
3+
🟠 <font color=#ffb800>Medium</font>&emsp; 🔖&ensp; [`递归`](/leetcode/outline/tag/recursion.md) [`链表`](/leetcode/outline/tag/linked-list.md) [`数学`](/leetcode/outline/tag/math.md)&emsp; 🔗&ensp;[`LeetCode`](https://leetcode.com/problems/add-two-numbers)
4+
5+
6+
## 题目
7+
8+
You are given two **non-empty** linked lists representing two non-negative
9+
integers. The digits are stored in **reverse order** , and each of their nodes
10+
contains a single digit. Add the two numbers and return the sum as a linked
11+
list.
12+
13+
You may assume the two numbers do not contain any leading zero, except the
14+
number 0 itself.
15+
16+
17+
18+
**Example 1:**
19+
20+
![](https://assets.leetcode.com/uploads/2020/10/02/addtwonumber1.jpg)
21+
22+
> Input: l1 = [2,4,3], l2 = [5,6,4]
23+
>
24+
> Output: [7,0,8]
25+
>
26+
> Explanation: 342 + 465 = 807.
27+
28+
**Example 2:**
29+
30+
> Input: l1 = [0], l2 = [0]
31+
>
32+
> Output: [0]
33+
34+
**Example 3:**
35+
36+
> Input: l1 = [9,9,9,9,9,9,9], l2 = [9,9,9,9]
37+
>
38+
> Output: [8,9,9,9,0,0,0,1]
39+
40+
**Constraints:**
41+
42+
* The number of nodes in each linked list is in the range `[1, 100]`.
43+
* `0 <= Node.val <= 9`
44+
* It is guaranteed that the list represents a number that does not have leading zeros.
45+
46+
47+
## 题目大意
48+
49+
给你两个 **非空** 的链表,表示两个非负的整数。它们每位数字都是按照 **逆序** 的方式存储的,并且每个节点只能存储 **一位** 数字。
50+
51+
请你将两个数相加,并以相同形式返回一个表示和的链表。
52+
53+
你可以假设除了数字 0 之外,这两个数都不会以 0 开头。
54+
55+
56+
57+
**示例 1:**
58+
59+
![](https://assets.leetcode-cn.com/aliyun-lc-
60+
upload/uploads/2021/01/02/addtwonumber1.jpg)
61+
62+
>
63+
>
64+
>
65+
>
66+
>
67+
> **输入:** l1 = [2,4,3], l2 = [5,6,4]
68+
>
69+
> **输出:**[7,0,8]
70+
>
71+
> **解释:** 342 + 465 = 807.
72+
>
73+
>
74+
75+
**示例 2:**
76+
77+
>
78+
>
79+
>
80+
>
81+
>
82+
> **输入:** l1 = [0], l2 = [0]
83+
>
84+
> **输出:**[0]
85+
>
86+
>
87+
88+
**示例 3:**
89+
90+
>
91+
>
92+
>
93+
>
94+
>
95+
> **输入:** l1 = [9,9,9,9,9,9,9], l2 = [9,9,9,9]
96+
>
97+
> **输出:**[8,9,9,9,0,0,0,1]
98+
>
99+
>
100+
101+
102+
103+
**提示:**
104+
105+
* 每个链表中的节点数在范围 `[1, 100]`
106+
* `0 <= Node.val <= 9`
107+
* 题目数据保证列表表示的数字不含前导零
108+
109+
110+
## 解题思路
111+
112+
#### 复杂度分析
113+
114+
- **时间复杂度**`O()`
115+
- **空间复杂度**`O()`
116+
117+
## 代码
118+
119+
```javascript
120+
121+
```
122+
123+
## 相关题目
124+
125+
:::: md-demo 相关题目
126+
- [字符串相乘](https://leetcode.com/problems/multiply-strings)
127+
- [二进制求和](https://leetcode.com/problems/add-binary)
128+
- [两整数之和](https://leetcode.com/problems/sum-of-two-integers)
129+
- [字符串相加](https://leetcode.com/problems/add-strings)
130+
- [两数相加 II](https://leetcode.com/problems/add-two-numbers-ii)
131+
- [数组形式的整数加法](https://leetcode.com/problems/add-to-array-form-of-integer)
132+
- [求两个多项式链表的和](https://leetcode.com/problems/add-two-polynomials-represented-as-linked-lists)
133+
- [翻倍以链表形式表示的数字](https://leetcode.com/problems/double-a-number-represented-as-a-linked-list)
134+
135+
::::

0 commit comments

Comments
 (0)