Skip to content

Commit

Permalink
feat: 增加公司标签,字节、bat (azl397985856#415)
Browse files Browse the repository at this point in the history
Co-authored-by: ygy <[email protected]>
  • Loading branch information
fly0o0 and ygy authored Aug 16, 2020
1 parent 15e1fa4 commit c972e16
Show file tree
Hide file tree
Showing 168 changed files with 941 additions and 11 deletions.
5 changes: 5 additions & 0 deletions problems/101.symmetric-tree.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,14 @@ https://leetcode-cn.com/problems/symmetric-tree/

## 公司

- 阿里
- 腾讯
- 百度
- 字节
- bloomberg
- linkedin
- microsoft

## 前置知识

- [二叉树](https://github.com/azl397985856/leetcode/blob/master/thinkings/basic-data-structure.md)
Expand Down
4 changes: 4 additions & 0 deletions problems/1011.capacity-to-ship-packages-within-d-days-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ https://leetcode-cn.com/problems/capacity-to-ship-packages-within-d-days

- 二分法

## 公司

- 阿里

## 思路

这道题和[猴子吃香蕉](https://github.com/azl397985856/leetcode/blob/master/problems/875.koko-eating-bananas.md) 简直一摸一样,没有看过的建议看一下那道题。
Expand Down
5 changes: 5 additions & 0 deletions problems/1014.best-sightseeing-pair.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ https://leetcode-cn.com/problems/best-sightseeing-pair/description/

- 动态规划

## 公司

- 阿里
- 字节

## 思路

最简单的思路就是两两组合,找出最大的,妥妥超时,我们来看下代码:
Expand Down
4 changes: 4 additions & 0 deletions problems/1015.smallest-integer-divisible-by-k.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ https://leetcode-cn.com/problems/smallest-integer-divisible-by-k/description/

- 循环节

## 公司

- 暂无

## 思路

这道题是说给定一个 K 值,能否找到一个形如 1,11,111,1111 。。。 这样的数字 n 使得 n % K == 0。
Expand Down
5 changes: 5 additions & 0 deletions problems/1019.next-greater-node-in-linked-list.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ https://leetcode-cn.com/problems/next-greater-node-in-linked-list/submissions/
- 链表
-

## 公司

- 腾讯
- 字节

## 思路

看完题目就应该想到单调栈才行,LeetCode 上关于单调栈的题目还不少,难度都不小。但是一旦你掌握了这个算法,那么这些题目对你来说都不是问题了。
Expand Down
7 changes: 7 additions & 0 deletions problems/102.binary-tree-level-order-traversal.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ https://leetcode.com/problems/binary-tree-level-order-traversal/description/

- 队列

## 公司

- 阿里
- 腾讯
- 百度
- 字节

## 思路

这是一个典型的二叉树遍历问题, 关于二叉树遍历,我总结了一个[专题](https://github.com/azl397985856/leetcode/blob/master/thinkings/binary-tree-traversal.md),大家可以先去看下那个,然后再来刷这道题。
Expand Down
4 changes: 4 additions & 0 deletions problems/1020.number-of-enclaves.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ class Solution:

## 解法二 (消除法)

## 公司

- 暂无

### 思路

上面的解法时间复杂度和空间复杂度都很差,我们考虑进行优化, 这里我们使用消除法。
Expand Down
4 changes: 4 additions & 0 deletions problems/1023.camelcase-matching.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ https://leetcode-cn.com/problems/camelcase-matching/

- 双指针

## 公司

- 暂无

## 思路

这道题是一道典型的双指针题目。不过这里的双指针并不是指向同一个数组或者字符串,而是指向多个,这道题是指向两个,分别是 query 和 pattern,这种题目非常常见,能够识别和掌握这种题目的解题模板非常重要。对 queries 的每一项我们的逻辑是一样的,这里就以其中一项为例进行讲解。
Expand Down
7 changes: 7 additions & 0 deletions problems/103.binary-tree-zigzag-level-order-traversal.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ return its zigzag level order traversal as:

- 队列

## 公司

- 阿里
- 腾讯
- 百度
- 字节

## 思路

这道题可以借助`队列`实现,首先把root入队,然后入队一个特殊元素Null(来表示每层的结束)。
Expand Down
4 changes: 4 additions & 0 deletions problems/1031.maximum-sum-of-two-non-overlapping-subarrays.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ L + M <= A.length <= 1000

- 数组

## 公司

- 字节

## 思路(动态规划)

题目中要求在前N(数组长度)个数中找出长度分别为L和M的非重叠子数组之和的最大值, 因此, 我们可以定义数组A中前i个数可构成的非重叠子数组L和M的最大值为SUMM[i], 并找到SUMM[i]和SUMM[i-1]的关系, 那么最终解就是SUMM[N]. 以下为图解:
Expand Down
4 changes: 4 additions & 0 deletions problems/1032.stream-of-characters.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ streamChecker.query('l'); // 返回 true,因为 'kl' 在字词表中

- 前缀树

## 公司

- 字节

## 思路

题目要求`按从旧到新顺序`查询,因此可以将从旧到新的 query 存起来形成一个单词 stream。
Expand Down
4 changes: 4 additions & 0 deletions problems/104.maximum-depth-of-binary-tree.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ return its depth = 3.

## 公司

- 阿里
- 腾讯
- 百度
- 字节
- apple
- linkedin
- uber
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ Return the following binary tree:

- 二叉树

## 公司

- 阿里
- 腾讯
- 百度
- 字节

## 思路/Thinking Path

目标是构造二叉树。
Expand Down
4 changes: 4 additions & 0 deletions problems/108.convert-sorted-array-to-binary-search-tree.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ https://leetcode-cn.com/problems/convert-sorted-array-to-binary-search-tree/

## 公司

- 阿里
- 腾讯
- 百度
- 字节
- airbnb

## 思路
Expand Down
3 changes: 3 additions & 0 deletions problems/11.container-with-most-water.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ https://leetcode-cn.com/problems/container-with-most-water/description/
## 公司

- 字节
- 腾讯
- 百度
- 阿里

## 思路

Expand Down
4 changes: 4 additions & 0 deletions problems/1104.path-in-zigzag-labelled-binary-tree.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ https://leetcode-cn.com/problems/path-in-zigzag-labelled-binary-tree/description

- 二叉树

## 公司

- 暂无

## 思路

假如这道题不是之字形,那么就会非常简单。 我们可以根据子节点的 label 轻松地求出父节点的 label,公示是 label // 2(其中 label 为子节点的 label)。
Expand Down
7 changes: 7 additions & 0 deletions problems/113.path-sum-ii.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ Return:

- 回溯法

## 公司

- 阿里
- 腾讯
- 百度
- 字节

## 思路

这道题目是求集合,并不是`求值`,而是枚举所有可能,因此动态规划不是特别切合,因此我们需要考虑别的方法。
Expand Down
6 changes: 6 additions & 0 deletions problems/1131.maximum-of-absolute-value-expression.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ https://leetcode-cn.com/problems/maximum-of-absolute-value-expression/descriptio

## 解法一(数学分析)

## 公司

- 阿里
- 腾讯
- 字节

### 思路

如图我们要求的是这样一个表达式的最大值。arr1 和 arr2 为两个不同的数组,且二者长度相同。i 和 j 是两个合法的索引。
Expand Down
3 changes: 3 additions & 0 deletions problems/1168.optimize-water-distribution-in-a-village-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ pipes[i][0] != pipes[i][1]
-
- 最小生成树

## 公司

- 暂无

## 思路

Expand Down
4 changes: 4 additions & 0 deletions problems/1186.maximum-subarray-sum-with-one-deletion.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ https://leetcode.com/problems/maximum-subarray-sum-with-one-deletion/
- 数组
- 动态规划

## 公司

- 字节

## 思路

### 暴力法
Expand Down
4 changes: 4 additions & 0 deletions problems/121.best-time-to-buy-and-sell-stock.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ Explanation: In this case, no transaction is done, i.e. max profit = 0.

## 公司

- 阿里
- 腾讯
- 百度
- 字节
- amazon
- bloomberg
- facebook
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ https://leetcode-cn.com/problems/longest-arithmetic-subsequence-of-given-differe
- 数组
- 动态规划

## 公司

- 腾讯

## 思路

最直观的思路是双层循环,我们暴力的枚举出以每一个元素为开始元素,以最后元素结尾的的所有情况。很明显这是所有的情况,这就是暴力法的精髓, 很明显这种解法会TLE(超时),不过我们先来看一下代码,顺着这个思维继续思考。
Expand Down
4 changes: 4 additions & 0 deletions problems/122.best-time-to-buy-and-sell-stock-ii.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ Explanation: In this case, no transaction is done, i.e. max profit = 0.

## 公司

- 阿里
- 腾讯
- 百度
- 字节
- bloomberg

## 思路
Expand Down
4 changes: 4 additions & 0 deletions problems/1227.airplane-seat-assignment-probability.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ https://leetcode-cn.com/problems/airplane-seat-assignment-probability/descriptio

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

## 公司

- 字节

### 思路

我们定义原问题为 f(n)。对于第一个人来说,他有 n 中选择,就是分别选择 n 个座位中的一个。由于选择每个位置的概率是相同的,那么选择每个位置的概率应该都是 1 / n。
Expand Down
3 changes: 3 additions & 0 deletions problems/124.binary-tree-maximum-path-sum.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ Output: 42

## 公司

- 阿里
- 腾讯
- 百度
- 字节

## 思路
Expand Down
4 changes: 4 additions & 0 deletions problems/125.valid-palindrome.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ Output: false

## 公司

- 阿里
- 腾讯
- 百度
- 字节
- facebook
- microsoft
- uber
Expand Down
4 changes: 4 additions & 0 deletions problems/1260.shift-2d-grid.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ https://leetcode-cn.com/problems/shift-2d-grid/description/

## 暴力法

## 公司

- 字节

### 思路

我们直接翻译题目,没有任何 hack 的做法。
Expand Down
4 changes: 4 additions & 0 deletions problems/1261.find-elements-in-a-contaminated-binary-tree.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ TreeNode.val == -1

## 暴力法

## 公司

- 暂无

### 思路

最简单想法就是递归建立树,然后 find 的时候递归查找即可,代码也很简单。
Expand Down
4 changes: 4 additions & 0 deletions problems/1262.greatest-sum-divisible-by-three.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ https://leetcode-cn.com/problems/greatest-sum-divisible-by-three/description/

## 暴力法

## 公司

- 字节

### 思路

一种方式是找出所有的能够被 3 整除的子集,然后挑选出和最大的。由于我们选出了所有的子集,那么时间复杂度就是 $O(2^N)$ , 毫无疑问会超时。这里我们使用回溯法找子集,如果不清楚回溯法,可以参考我之前的题解,很多题目都用到了,比如[78.subsets](https://github.com/azl397985856/leetcode/blob/master/problems/78.subsets.md)
Expand Down
7 changes: 7 additions & 0 deletions problems/128.longest-consecutive-sequence.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ Submissions

- hashmap

## 公司

- 阿里
- 腾讯
- 百度
- 字节

## 思路

这是一道最最长连续数字序列长度的题目, 官网给出的难度是`hard`.
Expand Down
6 changes: 6 additions & 0 deletions problems/129.sum-root-to-leaf-numbers.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ Therefore, sum = 495 + 491 + 40 = 1026.

- 递归

## 公司

- 阿里
- 百度
- 字节

## 思路

这是一道非常适合训练递归的题目。虽然题目不难,但是要想一次写正确,并且代码要足够优雅却不是很容易。
Expand Down
4 changes: 4 additions & 0 deletions problems/1297.maximum-number-of-occurrences-of-a-substring.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ s 只包含小写英文字母。

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

## 公司

- 字节

### 思路

暴力法如下:
Expand Down
7 changes: 7 additions & 0 deletions problems/130.surrounded-regions.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ Surrounded regions shouldn’t be on the border, which means that any 'O' on the

- DFS

## 公司

- 阿里
- 腾讯
- 百度
- 字节

## 思路

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

0 comments on commit c972e16

Please sign in to comment.