未验证 提交 c972e16d 编写于 作者: 羽飞 提交者: GitHub

feat: 增加公司标签,字节、bat (#415)

Co-authored-by: Nygy <ygy@duiba.com.cn>
上级 15e1fa48
......@@ -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)
......
......@@ -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) 简直一摸一样,没有看过的建议看一下那道题。
......
......@@ -25,6 +25,11 @@ https://leetcode-cn.com/problems/best-sightseeing-pair/description/
- 动态规划
## 公司
- 阿里
- 字节
## 思路
最简单的思路就是两两组合,找出最大的,妥妥超时,我们来看下代码:
......
......@@ -38,6 +38,10 @@ https://leetcode-cn.com/problems/smallest-integer-divisible-by-k/description/
- 循环节
## 公司
- 暂无
## 思路
这道题是说给定一个 K 值,能否找到一个形如 1,11,111,1111 。。。 这样的数字 n 使得 n % K == 0。
......
......@@ -40,6 +40,11 @@ https://leetcode-cn.com/problems/next-greater-node-in-linked-list/submissions/
- 链表
-
## 公司
- 腾讯
- 字节
## 思路
看完题目就应该想到单调栈才行,LeetCode 上关于单调栈的题目还不少,难度都不小。但是一旦你掌握了这个算法,那么这些题目对你来说都不是问题了。
......
......@@ -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),大家可以先去看下那个,然后再来刷这道题。
......
......@@ -104,6 +104,10 @@ class Solution:
## 解法二 (消除法)
## 公司
- 暂无
### 思路
上面的解法时间复杂度和空间复杂度都很差,我们考虑进行优化, 这里我们使用消除法。
......
......@@ -47,6 +47,10 @@ https://leetcode-cn.com/problems/camelcase-matching/
- 双指针
## 公司
- 暂无
## 思路
这道题是一道典型的双指针题目。不过这里的双指针并不是指向同一个数组或者字符串,而是指向多个,这道题是指向两个,分别是 query 和 pattern,这种题目非常常见,能够识别和掌握这种题目的解题模板非常重要。对 queries 的每一项我们的逻辑是一样的,这里就以其中一项为例进行讲解。
......
......@@ -27,6 +27,13 @@ return its zigzag level order traversal as:
- 队列
## 公司
- 阿里
- 腾讯
- 百度
- 字节
## 思路
这道题可以借助`队列`实现,首先把root入队,然后入队一个特殊元素Null(来表示每层的结束)。
......
......@@ -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]. 以下为图解:
......
......@@ -42,6 +42,10 @@ streamChecker.query('l'); // 返回 true,因为 'kl' 在字词表中
- 前缀树
## 公司
- 字节
## 思路
题目要求`按从旧到新顺序`查询,因此可以将从旧到新的 query 存起来形成一个单词 stream。
......
......@@ -30,6 +30,10 @@ return its depth = 3.
## 公司
- 阿里
- 腾讯
- 百度
- 字节
- apple
- linkedin
- uber
......
......@@ -30,6 +30,13 @@ Return the following binary tree:
- 二叉树
## 公司
- 阿里
- 腾讯
- 百度
- 字节
## 思路/Thinking Path
目标是构造二叉树。
......
......@@ -31,6 +31,10 @@ https://leetcode-cn.com/problems/convert-sorted-array-to-binary-search-tree/
## 公司
- 阿里
- 腾讯
- 百度
- 字节
- airbnb
## 思路
......
......@@ -33,6 +33,9 @@ https://leetcode-cn.com/problems/container-with-most-water/description/
## 公司
- 字节
- 腾讯
- 百度
- 阿里
## 思路
......
......@@ -31,6 +31,10 @@ https://leetcode-cn.com/problems/path-in-zigzag-labelled-binary-tree/description
- 二叉树
## 公司
- 暂无
## 思路
假如这道题不是之字形,那么就会非常简单。 我们可以根据子节点的 label 轻松地求出父节点的 label,公示是 label // 2(其中 label 为子节点的 label)。
......
......@@ -30,6 +30,13 @@ Return:
- 回溯法
## 公司
- 阿里
- 腾讯
- 百度
- 字节
## 思路
这道题目是求集合,并不是`求值`,而是枚举所有可能,因此动态规划不是特别切合,因此我们需要考虑别的方法。
......
......@@ -30,6 +30,12 @@ https://leetcode-cn.com/problems/maximum-of-absolute-value-expression/descriptio
## 解法一(数学分析)
## 公司
- 阿里
- 腾讯
- 字节
### 思路
如图我们要求的是这样一个表达式的最大值。arr1 和 arr2 为两个不同的数组,且二者长度相同。i 和 j 是两个合法的索引。
......
......@@ -33,6 +33,9 @@ pipes[i][0] != pipes[i][1]
-
- 最小生成树
## 公司
- 暂无
## 思路
......
......@@ -44,6 +44,10 @@ https://leetcode.com/problems/maximum-subarray-sum-with-one-deletion/
- 数组
- 动态规划
## 公司
- 字节
## 思路
### 暴力法
......
......@@ -30,6 +30,10 @@ Explanation: In this case, no transaction is done, i.e. max profit = 0.
## 公司
- 阿里
- 腾讯
- 百度
- 字节
- amazon
- bloomberg
- facebook
......
......@@ -39,6 +39,10 @@ https://leetcode-cn.com/problems/longest-arithmetic-subsequence-of-given-differe
- 数组
- 动态规划
## 公司
- 腾讯
## 思路
最直观的思路是双层循环,我们暴力的枚举出以每一个元素为开始元素,以最后元素结尾的的所有情况。很明显这是所有的情况,这就是暴力法的精髓, 很明显这种解法会TLE(超时),不过我们先来看一下代码,顺着这个思维继续思考。
......
......@@ -37,6 +37,10 @@ Explanation: In this case, no transaction is done, i.e. max profit = 0.
## 公司
- 阿里
- 腾讯
- 百度
- 字节
- bloomberg
## 思路
......
......@@ -45,6 +45,10 @@ https://leetcode-cn.com/problems/airplane-seat-assignment-probability/descriptio
这是一道 LeetCode 为数不多的概率题,我们来看下。
## 公司
- 字节
### 思路
我们定义原问题为 f(n)。对于第一个人来说,他有 n 中选择,就是分别选择 n 个座位中的一个。由于选择每个位置的概率是相同的,那么选择每个位置的概率应该都是 1 / n。
......
......@@ -37,6 +37,9 @@ Output: 42
## 公司
- 阿里
- 腾讯
- 百度
- 字节
## 思路
......
......@@ -28,6 +28,10 @@ Output: false
## 公司
- 阿里
- 腾讯
- 百度
- 字节
- facebook
- microsoft
- uber
......
......@@ -52,6 +52,10 @@ https://leetcode-cn.com/problems/shift-2d-grid/description/
## 暴力法
## 公司
- 字节
### 思路
我们直接翻译题目,没有任何 hack 的做法。
......
......@@ -78,6 +78,10 @@ TreeNode.val == -1
## 暴力法
## 公司
- 暂无
### 思路
最简单想法就是递归建立树,然后 find 的时候递归查找即可,代码也很简单。
......
......@@ -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)
......
......@@ -25,6 +25,13 @@ Submissions
- hashmap
## 公司
- 阿里
- 腾讯
- 百度
- 字节
## 思路
这是一道最最长连续数字序列长度的题目, 官网给出的难度是`hard`.
......
......@@ -45,6 +45,12 @@ Therefore, sum = 495 + 491 + 40 = 1026.
- 递归
## 公司
- 阿里
- 百度
- 字节
## 思路
这是一道非常适合训练递归的题目。虽然题目不难,但是要想一次写正确,并且代码要足够优雅却不是很容易。
......
......@@ -49,6 +49,10 @@ s 只包含小写英文字母。
题目给的数据量不是很大,为 1 <= maxLetters <= 26,我们试一下暴力法。
## 公司
- 字节
### 思路
暴力法如下:
......
......@@ -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的。
......
......@@ -25,6 +25,13 @@ Output:
- 回溯法
## 公司
- 阿里
- 腾讯
- 百度
- 字节
## 思路
这是一道求解所有可能性的题目, 这时候可以考虑使用回溯法。 回溯法解题的模板我们已经在很多题目中用过了,
......
......@@ -72,6 +72,10 @@ class Solution:
## 前缀表达式
## 公司
- 暂无
### 思路
比较常见的是前缀和,这个概念其实很容易理解,即一个数组中,第 n 位存储的是数组前 n 个数字的和。
......
......@@ -49,6 +49,10 @@ s 仅包含字母 'a'  和 'b'
- 回文
## 公司
- 暂无
## 思路
这又是一道“抖机灵”的题目,类似的题目有[1297.maximum-number-of-occurrences-of-a-substring](https://github.com/azl397985856/leetcode/blob/77db8fa47c7ee0a14b320f7c2d22f7c61ae53c35/problems/1297.maximum-number-of-occurrences-of-a-substring.md)
......
......@@ -69,6 +69,10 @@ edges[i].length == 3
- 动态规划
- Floyd-Warshall
## 公司
- 暂无
## 思路
这道题的本质就是:
......
......@@ -18,8 +18,11 @@ Your algorithm should have a linear runtime complexity. Could you implement it w
## 公司
- airbnb
- palantir
- 阿里
- 腾讯
- 百度
- 字节
## 思路
根据题目描述,由于加上了时间复杂度必须是 O(n),并且空间复杂度为 O(1)的条件,因此不能用排序方法,也不能使用 map 数据结构。
......
......@@ -40,6 +40,10 @@ s 只包含小写英文字母。
## 暴力法 + 剪枝
## 公司
- 暂无
### 思路
首先拿到这道题的时候,我想到第一反应是滑动窗口行不行。 但是很快这个想法就被我否定了,因为滑动窗口(这里是可变滑动窗口)我们需要扩张和收缩窗口大小,而这里不那么容易。因为题目要求的是奇偶性,而不是类似“元音出现最多的子串”等。
......
......@@ -34,6 +34,13 @@ Output: false
- 动态规划
## 公司
- 阿里
- 腾讯
- 百度
- 字节
## 思路
这道题是给定一个字典和一个句子,判断该句子是否可以由字典里面的单词组出来,一个单词可以用多次。
......
......@@ -26,6 +26,13 @@ Follow up: Recursive solution is trivial, could you do it iteratively?
- 递归
-
## 公司
- 阿里
- 腾讯
- 百度
- 字节
## 思路
这道题目是前序遍历,这个和之前的`leetcode 94 号问题 - 中序遍历`完全不一回事。
......
......@@ -59,7 +59,11 @@ cost.length == 9
- 数组
- 动态规划
-背包问题
- 背包问题
## 公司
- 暂无
## 思路
......
......@@ -27,6 +27,13 @@ Note: Recursive solution is trivial, could you do it iteratively?
-
- 递归
## 公司
- 阿里
- 腾讯
- 百度
- 字节
## 思路
相比于前序遍历,后续遍历思维上难度要大些,前序遍历是通过一个stack,首先压入父亲结点,然后弹出父亲结点,并输出它的value,之后压人其右儿子,左儿子即可。
......
......@@ -34,7 +34,10 @@ cache.get(4); // returns 4
## 公司
- 百度、字节
- 阿里
- 腾讯
- 百度
- 字节
## 思路
......
......@@ -31,7 +31,8 @@ A solution set is:
## 公司
- 阿里、字节
- 阿里
- 字节
## 思路
......
......@@ -20,6 +20,11 @@ The given RPN expression is always valid. That means the expression would always
-
## 公司
- 阿里
- 腾讯
## 思路
逆波兰表达式又叫做后缀表达式。在通常的表达式中,二元运算符总是置于与之相关的两个运算对象之间,这种表示法也称为`中缀表示`
......
......@@ -24,6 +24,13 @@ https://leetcode.com/problems/maximum-product-subarray/description/
- 滑动窗口
## 公司
- 阿里
- 腾讯
- 百度
- 字节
## 思路
这道题目要我们求解连续的 n 个数中乘积最大的积是多少。这里提到了连续,笔者首先想到的就是滑动窗口,但是这里比较特殊,我们不能仅仅维护一个最大值,因此最小值(比如-20)乘以一个比较小的数(比如-10)
......
......@@ -36,6 +36,13 @@ minStack.getMin(); --> Returns -2.
## 两个栈
## 公司
- 阿里
- 腾讯
- 百度
- 字节
### 思路
我们使用两个栈:
......
......@@ -29,6 +29,10 @@ Explanation: The sum of 2 and 7 is 9. Therefore index1 = 1, index2 = 2.
## 公司
- 阿里
- 腾讯
- 百度
- 字节
- amazon
## 思路
......
......@@ -26,6 +26,10 @@ Output: 2
## 公司
- 阿里
- 腾讯
- 百度
- 字节
- adobe
- zenefits
......
......@@ -23,6 +23,13 @@ https://leetcode-cn.com/problems/letter-combinations-of-a-phone-number
- 回溯
## 公司
- 阿里
- 百度
- 字节
- 腾讯
## 思路
使用回溯法进行求解,回溯是一种通过穷举所有可能情况来找到所有解的算法。如果一个候选解最后被发现并不是可行解,回溯算法会舍弃它,并在前面的一些步骤做出一些修改,并重新尝试找到可行解。究其本质,其实就是枚举。
......
......@@ -27,6 +27,9 @@ Note: Your solution should be in logarithmic time complexity.
## 公司
- 阿里
- 腾讯
- 百度
- bloomberg
## 思路
......
......@@ -24,6 +24,13 @@ Could you do this in one pass?
- 链表
- 双指针
## 公司
- 阿里
- 百度
- 腾讯
- 字节
## 思路
双指针,指针 A 先移动 n 次, 指针 B 再开始移动。当 A 到达 null 的时候, 指针 b 的位置正好是倒数 n
......
......@@ -33,6 +33,9 @@ In Java, the compiler represents the signed integers using 2's complement notati
## 公司
- 阿里
- 腾讯
- 百度
- airbnb
- apple
......
......@@ -38,6 +38,10 @@ In Java, the compiler represents the signed integers using 2's complement notati
## 公司
- 阿里
- 腾讯
- 百度
- 字节
- apple
- microsoft
......
......@@ -30,6 +30,10 @@ Explanation: Rob house 1 (money = 2), rob house 3 (money = 9) and rob house 5 (m
## 公司
- 阿里
- 腾讯
- 百度
- 字节
- airbnb
- linkedin
......
......@@ -23,6 +23,13 @@ Explanation:
## 前置知识
- 队列
## 公司
- 阿里
- 腾讯
- 百度
- 字节
## 思路
......
......@@ -23,7 +23,9 @@ Explanation: 342 + 465 = 807.
## 公司
- 阿里、百度、腾讯
- 阿里
- 百度
- 腾讯
## 思路
......
......@@ -41,6 +41,10 @@ Output: true
## 公司
- 阿里
- 百度
- 腾讯
- 字节
- airbnb
- amazon
- bloomberg
......
......@@ -31,6 +31,13 @@ Output: 3
## 前置知识
- DFS
## 公司
- 阿里
- 腾讯
- 百度
- 字节
## 思路
......
......@@ -21,6 +21,13 @@ Output: 0
## 前置知识
- 位运算
## 公司
- 阿里
- 腾讯
- 百度
- 字节
## 思路
......
......@@ -16,6 +16,13 @@ Output: 1->2->3->4->5
- [链表](https://github.com/azl397985856/leetcode/blob/master/thinkings/basic-data-structure.md)
## 公司
- 阿里
- 腾讯
- 百度
- 字节
## 思路
这个一个链表基本操作的题目,思路就不多说了。
## 关键点解析
......
......@@ -28,6 +28,13 @@ All inputs are guaranteed to be non-empty strings.
- 前缀树
## 公司
- 阿里
- 腾讯
- 百度
- 字节
## 思路
这是一道很直接的题目,上来就让你实现`前缀树(字典树)`。这算是基础数据结构中的
......
......@@ -20,6 +20,13 @@ If you have figured out the O(n) solution, try coding another solution of which
## 前置知识
- 滑动窗口
## 公司
- 阿里
- 腾讯
- 百度
- 字节
## 思路
......
......@@ -29,6 +29,10 @@ https://leetcode-cn.com/problems/merge-two-sorted-lists
- linkedin
- microsoft
## 公司
- 阿里、字节、腾讯
## 思路
使用递归来解题,将两个链表头部较小的一个与剩下的元素合并,并返回排好序的链表头,当两条链表中的一条为空时终止递归。
......
......@@ -29,6 +29,11 @@ search("b..") -> true
## 前置知识
- 前缀树
## 公司
- 阿里
- 腾讯
## 思路
......
......@@ -36,6 +36,11 @@ words = ["oath","pea","eat","rain"] and board =
- 前缀树
- DFS
## 公司
- 百度
- 字节
## 思路
我们需要对矩阵中每一项都进行深度优先遍历(DFS)。 递归的终点是
......
......@@ -22,6 +22,13 @@ You may assume k is always valid, 1 ≤ k ≤ array's length.
-
- Quick Select
## 公司
- 阿里
- 腾讯
- 百度
- 字节
## 思路
......
......@@ -26,6 +26,13 @@ Output: false
## 前置知识
- hashmap
## 公司
- 阿里
- 腾讯
- 百度
- 字节
## 思路
......
......@@ -25,6 +25,13 @@ https://leetcode-cn.com/problems/generate-parentheses
- DFS
- 回溯法
## 公司
- 阿里
- 百度
- 腾讯
- 字节
## 思路
深度优先搜索(回溯思想),从空字符串开始构造,做加法。
......
......@@ -25,6 +25,13 @@ Output: 4
- 动态规划
- 递归
## 公司
- 阿里
- 腾讯
- 百度
- 字节
## 思路
......
......@@ -32,6 +32,13 @@ Google: 90% of our engineers use the software you wrote (Homebrew), but you can
## 前置知识
- [递归](https://github.com/azl397985856/leetcode/blob/master/thinkings/dynamic-programming.md)
## 公司
- 阿里
- 腾讯
- 百度
- 字节
## 思路
遍历树(随便怎么遍历),然后将左右子树交换位置。
......
......@@ -22,6 +22,13 @@ Output: [1,2]
## 前置知识
- 摩尔投票法
## 公司
- 阿里
- 腾讯
- 百度
- 字节
## 思路
......
......@@ -21,6 +21,13 @@ https://leetcode-cn.com/problems/merge-k-sorted-lists/description/
- 链表
- 归并排序
## 公司
- 阿里
- 百度
- 腾讯
- 字节
## 思路
这道题目是合并 k 个已排序的链表,号称 leetcode 目前`最难`的链表题。 和之前我们解决的[88.merge-sorted-array](./88.merge-sorted-array.md)很像。
......
......@@ -38,6 +38,13 @@ What if the BST is modified (insert/delete operations) often and you need to fin
## 前置知识
- 中序遍历
## 公司
- 阿里
- 腾讯
- 百度
- 字节
## 思路
......
......@@ -33,6 +33,10 @@ You may assume that all operations are valid (for example, no pop or peek operat
## 公司
- 阿里
- 腾讯
- 百度
- 字节
- bloomberg
- microsoft
......
......@@ -36,6 +36,13 @@ p and q are different and both values will exist in the binary tree.
## 前置知识
- 递归
## 公司
- 阿里
- 腾讯
- 百度
- 字节
## 思路
......
......@@ -28,6 +28,13 @@ https://leetcode.com/problems/product-of-array-except-self/description/
## 前置知识
- 数组
## 公司
- 阿里
- 腾讯
- 百度
- 字节
## 思路
......
......@@ -33,6 +33,13 @@ Could you solve it in linear time?
- 队列
- 滑动窗口
## 公司
- 阿里
- 腾讯
- 百度
- 字节
## 思路
符合直觉的想法是直接遍历 nums, 然后然后用一个变量 slideWindow 去承载 k 个元素,
......
......@@ -16,6 +16,13 @@ Given 1->2->3->4, you should return the list as 2->1->4->3.
- 链表
## 公司
- 阿里
- 腾讯
- 百度
- 字节
## 思路
设置一个 dummy 节点简化操作,dummy next 指向 head。
......
......@@ -29,6 +29,13 @@ Given target = 20, return false.
## 前置知识
- 数组
## 公司
- 阿里
- 腾讯
- 百度
- 字节
## 思路
......
......@@ -28,6 +28,13 @@ You may not alter the values in the list's nodes, only nodes itself may be chang
- 链表
## 公司
- 阿里
- 腾讯
- 百度
- 字节
## 思路
题意是以 `k` 个 nodes 为一组进行翻转,返回翻转后的`linked list`.
......
......@@ -46,6 +46,10 @@ for (int i = 0; i < len; i++) {
## 公司
- 阿里
- 腾讯
- 百度
- 字节
- bloomberg
- facebook
- microsoft
......
......@@ -36,7 +36,13 @@ Input is within the 32-bit signed integer range: [−231, 231 − 1].
- 数学
- 因数分解
## 公司
- 阿里
- 腾讯
- 百度
- 字节
## 思路
题目要求给定一个数字,判断是否为“丑陋数”(ugly number), 丑陋数是指只包含质因子2, 3, 5的正整数。
......
......@@ -24,6 +24,12 @@ Explanation: 13 = 4 + 9.
- 递归
- 动态规划
## 公司
- 阿里
- 百度
- 字节
## 思路
......
......@@ -24,6 +24,10 @@ Minimize the total number of operations.
## 公司
- 阿里
- 腾讯
- 百度
- 字节
- bloomberg
- facebook
......
......@@ -29,6 +29,13 @@ Assume we are dealing with an environment which could only store integers within
- 二分法
## 公司
- 阿里
- 腾讯
- 百度
- 字节
## 思路
符合直觉的做法是,减数一次一次减去被减数,不断更新差,直到差小于0,我们减了多少次,结果就是多少。
......
......@@ -38,6 +38,12 @@ If 99% of all integer numbers from the stream are between 0 and 100, how would y
-
- 队列
## 公司
- 阿里
- 百度
- 字节
## 思路
......
......@@ -23,7 +23,9 @@ Given "pwwkew", the answer is "wke", with the length of 3. Note that the answer
## 公司
- 阿里、字节、腾讯
- 阿里
- 字节
- 腾讯
## 思路
......
......@@ -36,6 +36,13 @@ https://leetcode-cn.com/problems/substring-with-concatenation-of-all-words/descr
- 数组
- 哈希表
## 公司
- 阿里
- 腾讯
- 百度
- 字节
## 思路
本题是要我们找出 words 中`所有单词按照任意顺序串联`形成的单词中恰好出现在 s 中的索引,因此顺序是不重要的。换句话说,我们只要统计每一个单词的出现情况即可。以题目中 s = "barfoothefoobarman", words = ["foo","bar"] 为例。 我们只需要统计 foo 出现了一次,bar 出现了一次即可。我们只需要在 s 中找到同样包含一次 foo 和一次 bar 的子串即可。由于 words 中的字符串都是等长的,因此编码上也会比较简单。
......
......@@ -27,6 +27,13 @@ Output: [""]
- BFS
- 队列
## 公司
- 阿里
- 腾讯
- 百度
- 字节
## 思路
......
......@@ -21,6 +21,12 @@ Explanation: transactions = [buy, sell, cooldown, buy, sell]
## 前置知识
- 动态规划
## 公司
- 阿里
- 腾讯
- 字节
## 思路
......
......@@ -23,6 +23,13 @@ Here are some examples. Inputs are in the left-hand column and its corresponding
- 回溯法
## 公司
- 阿里
- 腾讯
- 百度
- 字节
## 思路
符合直觉的方法是我们按顺序求出所有的排列,如果当前排列等于 nums,那么我直接取下一个
......
......@@ -27,6 +27,13 @@ https://leetcode-cn.com/problems/burst-balloons/
- 回溯法
- 动态规划
## 公司
- 阿里
- 腾讯
- 百度
- 字节
### 思路
......
......@@ -25,6 +25,13 @@ Explanation: The longest valid parentheses substring is "()()"
## 暴力(超时)
## 公司
- 阿里
- 腾讯
- 百度
- 字节
### 思路
符合直觉的做法是:分别计算以 i 开头的 最长有效括号(i 从 0 到 n - 1·),从中取出最大的即可。
......
......@@ -26,6 +26,9 @@ You may assume that you have an infinite number of each kind of coin.
## 公司
- 腾讯
- 百度
- 字节
- 阿里巴巴(盒马生鲜)
## 岗位信息
......
......@@ -26,6 +26,13 @@ The first node is considered odd, the second node even and so on ...
## 前置知识
- 链表
## 公司
- 阿里
- 腾讯
- 百度
- 字节
## 思路
......
......@@ -30,6 +30,13 @@ Output: -1
- 数组
- 二分法
## 公司
- 阿里
- 腾讯
- 百度
- 字节
## 思路
这是一个我在网上看到的前端头条技术终面的一个算法题。
......
......@@ -27,6 +27,11 @@ Output: false
- 双指针
## 公司
- 百度
- 字节
## 思路
这道题是求解顺序数字是否有三个递增的排列, 注意这里没有要求连续的,因此诸如滑动窗口的思路是不可以的。
题目要求O(n)的时间复杂度和O(1)的空间复杂度,因此暴力的做法就不用考虑了。
......
......@@ -45,6 +45,10 @@ https://leetcode-cn.com/problems/self-crossing/
- 滑动窗口
## 公司
- 暂无
## 思路
符合直觉的做法是$O(N)$时间和空间复杂度的算法。这种算法非常简单,但是题目要求我们使用空间复杂度为$O(1)$的做法。
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册