Skip to content

Commit c972e16

Browse files
fly0o0ygy
and
ygy
authored
feat: 增加公司标签,字节、bat (azl397985856#415)
Co-authored-by: ygy <[email protected]>
1 parent 15e1fa4 commit c972e16

File tree

168 files changed

+941
-11
lines changed

Some content is hidden

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

168 files changed

+941
-11
lines changed

problems/101.symmetric-tree.md

+5
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,14 @@ https://leetcode-cn.com/problems/symmetric-tree/
3636

3737
## 公司
3838

39+
- 阿里
40+
- 腾讯
41+
- 百度
42+
- 字节
3943
- bloomberg
4044
- linkedin
4145
- microsoft
46+
4247
## 前置知识
4348

4449
- [二叉树](https://github.com/azl397985856/leetcode/blob/master/thinkings/basic-data-structure.md)

problems/1011.capacity-to-ship-packages-within-d-days-cn.md

+4
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ https://leetcode-cn.com/problems/capacity-to-ship-packages-within-d-days
5151

5252
- 二分法
5353

54+
## 公司
55+
56+
- 阿里
57+
5458
## 思路
5559

5660
这道题和[猴子吃香蕉](https://github.com/azl397985856/leetcode/blob/master/problems/875.koko-eating-bananas.md) 简直一摸一样,没有看过的建议看一下那道题。

problems/1014.best-sightseeing-pair.md

+5
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ https://leetcode-cn.com/problems/best-sightseeing-pair/description/
2525

2626
- 动态规划
2727

28+
## 公司
29+
30+
- 阿里
31+
- 字节
32+
2833
## 思路
2934

3035
最简单的思路就是两两组合,找出最大的,妥妥超时,我们来看下代码:

problems/1015.smallest-integer-divisible-by-k.md

+4
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ https://leetcode-cn.com/problems/smallest-integer-divisible-by-k/description/
3838

3939
- 循环节
4040

41+
## 公司
42+
43+
- 暂无
44+
4145
## 思路
4246

4347
这道题是说给定一个 K 值,能否找到一个形如 1,11,111,1111 。。。 这样的数字 n 使得 n % K == 0。

problems/1019.next-greater-node-in-linked-list.md

+5
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ https://leetcode-cn.com/problems/next-greater-node-in-linked-list/submissions/
4040
- 链表
4141
-
4242

43+
## 公司
44+
45+
- 腾讯
46+
- 字节
47+
4348
## 思路
4449

4550
看完题目就应该想到单调栈才行,LeetCode 上关于单调栈的题目还不少,难度都不小。但是一旦你掌握了这个算法,那么这些题目对你来说都不是问题了。

problems/102.binary-tree-level-order-traversal.md

+7
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ https://leetcode.com/problems/binary-tree-level-order-traversal/description/
2929

3030
- 队列
3131

32+
## 公司
33+
34+
- 阿里
35+
- 腾讯
36+
- 百度
37+
- 字节
38+
3239
## 思路
3340

3441
这是一个典型的二叉树遍历问题, 关于二叉树遍历,我总结了一个[专题](https://github.com/azl397985856/leetcode/blob/master/thinkings/binary-tree-traversal.md),大家可以先去看下那个,然后再来刷这道题。

problems/1020.number-of-enclaves.md

+4
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ class Solution:
104104

105105
## 解法二 (消除法)
106106

107+
## 公司
108+
109+
- 暂无
110+
107111
### 思路
108112

109113
上面的解法时间复杂度和空间复杂度都很差,我们考虑进行优化, 这里我们使用消除法。

problems/1023.camelcase-matching.md

+4
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ https://leetcode-cn.com/problems/camelcase-matching/
4747

4848
- 双指针
4949

50+
## 公司
51+
52+
- 暂无
53+
5054
## 思路
5155

5256
这道题是一道典型的双指针题目。不过这里的双指针并不是指向同一个数组或者字符串,而是指向多个,这道题是指向两个,分别是 query 和 pattern,这种题目非常常见,能够识别和掌握这种题目的解题模板非常重要。对 queries 的每一项我们的逻辑是一样的,这里就以其中一项为例进行讲解。

problems/103.binary-tree-zigzag-level-order-traversal.md

+7
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ return its zigzag level order traversal as:
2727

2828
- 队列
2929

30+
## 公司
31+
32+
- 阿里
33+
- 腾讯
34+
- 百度
35+
- 字节
36+
3037
## 思路
3138

3239
这道题可以借助`队列`实现,首先把root入队,然后入队一个特殊元素Null(来表示每层的结束)。

problems/1031.maximum-sum-of-two-non-overlapping-subarrays.md

+4
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ L + M <= A.length <= 1000
4141

4242
- 数组
4343

44+
## 公司
45+
46+
- 字节
47+
4448
## 思路(动态规划)
4549

4650
题目中要求在前N(数组长度)个数中找出长度分别为L和M的非重叠子数组之和的最大值, 因此, 我们可以定义数组A中前i个数可构成的非重叠子数组L和M的最大值为SUMM[i], 并找到SUMM[i]和SUMM[i-1]的关系, 那么最终解就是SUMM[N]. 以下为图解:

problems/1032.stream-of-characters.md

+4
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ streamChecker.query('l'); // 返回 true,因为 'kl' 在字词表中
4242

4343
- 前缀树
4444

45+
## 公司
46+
47+
- 字节
48+
4549
## 思路
4650

4751
题目要求`按从旧到新顺序`查询,因此可以将从旧到新的 query 存起来形成一个单词 stream。

problems/104.maximum-depth-of-binary-tree.md

+4
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ return its depth = 3.
3030

3131
## 公司
3232

33+
- 阿里
34+
- 腾讯
35+
- 百度
36+
- 字节
3337
- apple
3438
- linkedin
3539
- uber

problems/105.Construct-Binary-Tree-from-Preorder-and-Inorder-Traversal.md

+7
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ Return the following binary tree:
3030

3131
- 二叉树
3232

33+
## 公司
34+
35+
- 阿里
36+
- 腾讯
37+
- 百度
38+
- 字节
39+
3340
## 思路/Thinking Path
3441

3542
目标是构造二叉树。

problems/108.convert-sorted-array-to-binary-search-tree.md

+4
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ https://leetcode-cn.com/problems/convert-sorted-array-to-binary-search-tree/
3131

3232
## 公司
3333

34+
- 阿里
35+
- 腾讯
36+
- 百度
37+
- 字节
3438
- airbnb
3539

3640
## 思路

problems/11.container-with-most-water.md

+3
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ https://leetcode-cn.com/problems/container-with-most-water/description/
3333
## 公司
3434

3535
- 字节
36+
- 腾讯
37+
- 百度
38+
- 阿里
3639

3740
## 思路
3841

problems/1104.path-in-zigzag-labelled-binary-tree.md

+4
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ https://leetcode-cn.com/problems/path-in-zigzag-labelled-binary-tree/description
3131

3232
- 二叉树
3333

34+
## 公司
35+
36+
- 暂无
37+
3438
## 思路
3539

3640
假如这道题不是之字形,那么就会非常简单。 我们可以根据子节点的 label 轻松地求出父节点的 label,公示是 label // 2(其中 label 为子节点的 label)。

problems/113.path-sum-ii.md

+7
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ Return:
3030

3131
- 回溯法
3232

33+
## 公司
34+
35+
- 阿里
36+
- 腾讯
37+
- 百度
38+
- 字节
39+
3340
## 思路
3441

3542
这道题目是求集合,并不是`求值`,而是枚举所有可能,因此动态规划不是特别切合,因此我们需要考虑别的方法。

problems/1131.maximum-of-absolute-value-expression.md

+6
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ https://leetcode-cn.com/problems/maximum-of-absolute-value-expression/descriptio
3030

3131
## 解法一(数学分析)
3232

33+
## 公司
34+
35+
- 阿里
36+
- 腾讯
37+
- 字节
38+
3339
### 思路
3440

3541
如图我们要求的是这样一个表达式的最大值。arr1 和 arr2 为两个不同的数组,且二者长度相同。i 和 j 是两个合法的索引。

problems/1168.optimize-water-distribution-in-a-village-cn.md

+3
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ pipes[i][0] != pipes[i][1]
3333
-
3434
- 最小生成树
3535

36+
## 公司
37+
38+
- 暂无
3639

3740
## 思路
3841

problems/1186.maximum-subarray-sum-with-one-deletion.md

+4
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ https://leetcode.com/problems/maximum-subarray-sum-with-one-deletion/
4444
- 数组
4545
- 动态规划
4646

47+
## 公司
48+
49+
- 字节
50+
4751
## 思路
4852

4953
### 暴力法

problems/121.best-time-to-buy-and-sell-stock.md

+4
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ Explanation: In this case, no transaction is done, i.e. max profit = 0.
3030

3131
## 公司
3232

33+
- 阿里
34+
- 腾讯
35+
- 百度
36+
- 字节
3337
- amazon
3438
- bloomberg
3539
- facebook

problems/1218.longest-arithmetic-subsequence-of-given-difference.md

+4
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ https://leetcode-cn.com/problems/longest-arithmetic-subsequence-of-given-differe
3939
- 数组
4040
- 动态规划
4141

42+
## 公司
43+
44+
- 腾讯
45+
4246
## 思路
4347

4448
最直观的思路是双层循环,我们暴力的枚举出以每一个元素为开始元素,以最后元素结尾的的所有情况。很明显这是所有的情况,这就是暴力法的精髓, 很明显这种解法会TLE(超时),不过我们先来看一下代码,顺着这个思维继续思考。

problems/122.best-time-to-buy-and-sell-stock-ii.md

+4
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ Explanation: In this case, no transaction is done, i.e. max profit = 0.
3737

3838
## 公司
3939

40+
- 阿里
41+
- 腾讯
42+
- 百度
43+
- 字节
4044
- bloomberg
4145

4246
## 思路

problems/1227.airplane-seat-assignment-probability.md

+4
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ https://leetcode-cn.com/problems/airplane-seat-assignment-probability/descriptio
4545

4646
这是一道 LeetCode 为数不多的概率题,我们来看下。
4747

48+
## 公司
49+
50+
- 字节
51+
4852
### 思路
4953

5054
我们定义原问题为 f(n)。对于第一个人来说,他有 n 中选择,就是分别选择 n 个座位中的一个。由于选择每个位置的概率是相同的,那么选择每个位置的概率应该都是 1 / n。

problems/124.binary-tree-maximum-path-sum.md

+3
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ Output: 42
3737

3838
## 公司
3939

40+
- 阿里
41+
- 腾讯
42+
- 百度
4043
- 字节
4144

4245
## 思路

problems/125.valid-palindrome.md

+4
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ Output: false
2828

2929
## 公司
3030

31+
- 阿里
32+
- 腾讯
33+
- 百度
34+
- 字节
3135
- facebook
3236
- microsoft
3337
- uber

problems/1260.shift-2d-grid.md

+4
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ https://leetcode-cn.com/problems/shift-2d-grid/description/
5252

5353
## 暴力法
5454

55+
## 公司
56+
57+
- 字节
58+
5559
### 思路
5660

5761
我们直接翻译题目,没有任何 hack 的做法。

problems/1261.find-elements-in-a-contaminated-binary-tree.md

+4
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ TreeNode.val == -1
7878

7979
## 暴力法
8080

81+
## 公司
82+
83+
- 暂无
84+
8185
### 思路
8286

8387
最简单想法就是递归建立树,然后 find 的时候递归查找即可,代码也很简单。

problems/1262.greatest-sum-divisible-by-three.md

+4
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ https://leetcode-cn.com/problems/greatest-sum-divisible-by-three/description/
4141

4242
## 暴力法
4343

44+
## 公司
45+
46+
- 字节
47+
4448
### 思路
4549

4650
一种方式是找出所有的能够被 3 整除的子集,然后挑选出和最大的。由于我们选出了所有的子集,那么时间复杂度就是 $O(2^N)$ , 毫无疑问会超时。这里我们使用回溯法找子集,如果不清楚回溯法,可以参考我之前的题解,很多题目都用到了,比如[78.subsets](https://github.com/azl397985856/leetcode/blob/master/problems/78.subsets.md)

problems/128.longest-consecutive-sequence.md

+7
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ Submissions
2525

2626
- hashmap
2727

28+
## 公司
29+
30+
- 阿里
31+
- 腾讯
32+
- 百度
33+
- 字节
34+
2835
## 思路
2936

3037
这是一道最最长连续数字序列长度的题目, 官网给出的难度是`hard`.

problems/129.sum-root-to-leaf-numbers.md

+6
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ Therefore, sum = 495 + 491 + 40 = 1026.
4545

4646
- 递归
4747

48+
## 公司
49+
50+
- 阿里
51+
- 百度
52+
- 字节
53+
4854
## 思路
4955

5056
这是一道非常适合训练递归的题目。虽然题目不难,但是要想一次写正确,并且代码要足够优雅却不是很容易。

problems/1297.maximum-number-of-occurrences-of-a-substring.md

+4
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ s 只包含小写英文字母。
4949

5050
题目给的数据量不是很大,为 1 <= maxLetters <= 26,我们试一下暴力法。
5151

52+
## 公司
53+
54+
- 字节
55+
5256
### 思路
5357

5458
暴力法如下:

problems/130.surrounded-regions.md

+7
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ Surrounded regions shouldn’t be on the border, which means that any 'O' on the
3131

3232
- DFS
3333

34+
## 公司
35+
36+
- 阿里
37+
- 腾讯
38+
- 百度
39+
- 字节
40+
3441
## 思路
3542

3643
我们需要将所有被X包围的O变成X,并且题目明确说了边缘的所有O都是不可以变成X的。

0 commit comments

Comments
 (0)