-
-
Notifications
You must be signed in to change notification settings - Fork 9.5k
feat(公司标签): 1,2,3,4,5,11,15,21,42,53,124,146,206 #404
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -30,6 +30,10 @@ https://leetcode-cn.com/problems/container-with-most-water/description/ | |||||
|
||||||
- 双指针 | ||||||
|
||||||
## 公司 | ||||||
|
||||||
- 字节 | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
## 思路 | ||||||
|
||||||
题目中说`找出其中的两条线,使得它们与 x 轴共同构成的容器可以容纳最多的水。` ,因此符合直觉的解法就是固定两个端点,计算可以承载的水量, 然后不断更新最大值,最后返回最大值即可。这种算法,需要两层循环,时间复杂度是 $O(n^2)$。 | ||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -35,6 +35,10 @@ Output: 42 | |||||
|
||||||
- 递归 | ||||||
|
||||||
## 公司 | ||||||
|
||||||
- 字节 | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
## 思路 | ||||||
|
||||||
这道题目的path让我误解了,然后浪费了很多时间来解这道题 | ||||||
|
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -32,6 +32,10 @@ cache.get(4); // returns 4 | |||||||
|
||||||||
- 队列 | ||||||||
|
||||||||
## 公司 | ||||||||
|
||||||||
- 百度、字节 | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
|
||||||||
## 思路 | ||||||||
|
||||||||
`本题已被收录到我的新书中,敬请期待~` | ||||||||
|
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -29,6 +29,10 @@ A solution set is: | |||||||
- 双指针 | ||||||||
- 分治 | ||||||||
|
||||||||
## 公司 | ||||||||
|
||||||||
- 阿里、字节 | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
|
||||||||
## 思路 | ||||||||
|
||||||||
我们采用`分治`的思想. 想要找出三个数相加等于 0,我们可以数组依次遍历, | ||||||||
|
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -21,6 +21,10 @@ Explanation: 342 + 465 = 807. | |||||||||
|
||||||||||
- 链表 | ||||||||||
|
||||||||||
## 公司 | ||||||||||
|
||||||||||
- 阿里、百度、腾讯 | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
||||||||||
## 思路 | ||||||||||
|
||||||||||
设立一个表示进位的变量 carried,建立一个新链表, | ||||||||||
|
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -18,6 +18,10 @@ A linked list can be reversed either iteratively or recursively. Could you imple | |||||||||
|
||||||||||
- 链表 | ||||||||||
|
||||||||||
## 公司 | ||||||||||
|
||||||||||
- 阿里、百度、腾讯 | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
||||||||||
## 思路 | ||||||||||
|
||||||||||
这个就是常规操作了,使用一个变量记录前驱 pre,一个变量记录后继 next. | ||||||||||
|
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -19,6 +19,10 @@ https://leetcode-cn.com/problems/merge-two-sorted-lists | |||||||||
- 递归 | ||||||||||
- 链表 | ||||||||||
|
||||||||||
## 公司 | ||||||||||
|
||||||||||
- 阿里、字节、腾讯 | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
||||||||||
## 思路 | ||||||||||
|
||||||||||
使用递归来解题,将两个链表头部较小的一个与剩下的元素合并,并返回排好序的链表头,当两条链表中的一条为空时终止递归。 | ||||||||||
|
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -21,6 +21,10 @@ Given "pwwkew", the answer is "wke", with the length of 3. Note that the answer | |||||||||
- 哈希表 | ||||||||||
- [滑动窗口](https://github.com/azl397985856/leetcode/blob/master/thinkings/slide-window.md) | ||||||||||
|
||||||||||
## 公司 | ||||||||||
|
||||||||||
- 阿里、字节、腾讯 | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
||||||||||
## 思路 | ||||||||||
|
||||||||||
用一个 hashmap 来建立字符和其出现位置之间的映射。同时维护一个滑动窗口,窗口内的都是没有重复的字符,去尽可能的扩大窗口的大小,窗口不停的向右滑动。 | ||||||||||
|
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -34,6 +34,10 @@ nums2 = [3, 4] | |||||||||
- 分治法 | ||||||||||
- 二分查找 | ||||||||||
|
||||||||||
## 公司 | ||||||||||
|
||||||||||
- 阿里、百度、腾讯 | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
||||||||||
## 思路 | ||||||||||
|
||||||||||
首先了解一下 Median 的概念,一个数组中 median 就是把数组分成左右等分的中位数。 | ||||||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -29,6 +29,10 @@ Output: 6 | |||||
- 双指针 | ||||||
- 单调栈 | ||||||
|
||||||
## 公司 | ||||||
|
||||||
- 字节 | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
## 双数组 | ||||||
|
||||||
### 思路 | ||||||
|
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -20,6 +20,10 @@ https://leetcode-cn.com/problems/longest-palindromic-substring/ | |||||||||
|
||||||||||
- 回文 | ||||||||||
|
||||||||||
## 公司 | ||||||||||
|
||||||||||
- 阿里、百度、腾讯 | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
||||||||||
## 思路 | ||||||||||
|
||||||||||
这是一道最长回文的题目,要我们求出给定字符串的最大回文子串。 | ||||||||||
|
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -15,6 +15,10 @@ Follow up: | |||||||||||
If you have figured out the O(n) solution, try coding another solution using the divide and conquer approach, which is more subtle. | ||||||||||||
``` | ||||||||||||
|
||||||||||||
## 公司 | ||||||||||||
|
||||||||||||
- 阿里、百度、字节、腾讯 | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
|
||||||||||||
## 思路 | ||||||||||||
|
||||||||||||
这道题求解连续最大子序列和,以下从时间复杂度角度分析不同的解题思路。 | ||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.