-
Notifications
You must be signed in to change notification settings - Fork 110
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
TwoPointers #27
base: docsify
Are you sure you want to change the base?
TwoPointers #27
Conversation
|
||
针对以上的三种类型,都给出了模版。可是就像weiwei大佬说的[link](https://ojeveryday.github.io/AlgoWiki/#/BinarySearch/01-introduction?id=%e4%ba%8c%e5%88%86%e6%9f%a5%e6%89%be%e7%9a%84%e4%b8%89%e4%b8%aa%e6%a8%a1%e6%9d%bf),仅供参考哈。模版的意义在于可以帮助减少对某些边界条件的考虑以及对于某些问题的多想,节约脑细胞。 | ||
|
||
一般来说我们都需要用到两个变量,分别表示两个idx,一般是数组或者字符串中的idx。 |
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.
idx
这种缩写不知道是不是规范,可以说两个下标(索引),或者就说两个变量,问题都不大。
因为双指针就是在解决问题的过程中,使用的两个变量。
|
||
NOTE: | ||
|
||
滑动窗口应该算是双指针的一种应用,同时还可以用queue来实现。 |
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.
- 同上,「应该算」建议删去;
+「同时还可以用queue来实现。」建议删去。
return head.next | ||
|
||
slow = head | ||
quick = head |
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.
前面快慢指针命名用 fast,这里命名也需要统一用成 fast。
right+=1 | ||
if flag==flag_t: | ||
if right-left<res[0]: | ||
print(source[left:right]) |
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.
print
这样的语句需要从示例代码中删除。
@@ -0,0 +1,152 @@ | |||
+ # 相向双指针 | |||
|
|||
相向双指针主要是指两个指针面对面走,常见需要掌握的题目一般有下列: |
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.
「指针对撞」的问题例题建议的顺序是:
- 第 167 题
- 第 11 题
- 第 15 题
- (前 3 题是典型问题)其它相关问题
并且建议尽量通俗地讲清楚,是怎么想到指针一头一尾相向,然后简单说明合理性。
|
||
#### [658. 找到 K 个最接近的元素](https://leetcode-cn.com/problems/find-k-closest-elements/) | ||
|
||
```python |
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.
这个题目没有说思路,建议简单说明一下。
知识点和例题上面没有太多问题,反馈意见如下:
|
要在 sidebar 里面添加一下自己的 markdown 文件哈 |
我以前为了看预览,自己加了上去,不知道是不是对原作者有用。
|
add two pointer