mirror of
https://github.com/labuladong/fucking-algorithm.git
synced 2025-07-04 11:22:59 +08:00
update content
This commit is contained in:
21
.github/ISSUE_TEMPLATE/bug_report.md
vendored
21
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@ -1,21 +0,0 @@
|
||||
---
|
||||
name: 发现问题
|
||||
about: 我发现了某处链接或者知识点的错误
|
||||
title: 'bug '
|
||||
labels: bug
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
<!--
|
||||
标题为 bug + 简要描述,内容一定要基于以下模板,根据你的具体内容进行修改
|
||||
|
||||
以上为注释,不会显示在 issue 中。 -->
|
||||
|
||||
你好,我发现如下文章有 bug(点击文字可跳转到相关文章):
|
||||
|
||||
[动态规划系列/抢房子.md](https://github.com/labuladong/fucking-algorithm/blob/master/动态规划系列/抢房子.md)
|
||||
|
||||
问题描述:
|
||||
|
||||
某章图片链接失效/其中的 XXX 内容有误/等等。
|
44
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
Normal file
44
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
Normal file
@ -0,0 +1,44 @@
|
||||
name: 报告错误的解法代码
|
||||
title: "[bug] {这里替换为出错的力扣题号和题目} {这里替换为出错的编程语言}"
|
||||
description:
|
||||
labels: [ "code bug" ]
|
||||
body:
|
||||
- type: checkboxes
|
||||
attributes:
|
||||
label: Search before asking
|
||||
description: >
|
||||
请先搜索 [issues](https://github.com/labuladong/fucking-algorithm/issues) 确保你提的这个 bug 还没有被提交过。
|
||||
options:
|
||||
- label: >
|
||||
我已经搜索过 [issues](https://github.com/labuladong/fucking-algorithm/issues),没有发现相同的 bug。
|
||||
required: true
|
||||
- type: input
|
||||
attributes:
|
||||
label: 出错的题目链接
|
||||
description: |
|
||||
输入力扣的题目链接
|
||||
placeholder: e.g. https://leetcode.cn/problems/search-a-2d-matrix/
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: 报错信息
|
||||
description: |
|
||||
把出错的原因复制粘贴在这里
|
||||
value: |
|
||||
<!-- 把报错粘贴到下面的 ``` 块中 -->
|
||||
```
|
||||
|
||||
```
|
||||
validations:
|
||||
required: true
|
||||
- type: checkboxes
|
||||
attributes:
|
||||
label: 你是否愿意提交 PR 修复这个 bug?
|
||||
description: >
|
||||
PR 规范 [见这里](https://github.com/labuladong/fucking-algorithm/issues/1113),欢迎成为本仓库的 contributor!
|
||||
options:
|
||||
- label: 我愿意!
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: "感谢你的支持,刷题全家桶会因你变得越来越好!"
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
title: '东哥手把手带你刷二叉树(纲领篇)'
|
||||
tags: ['数据结构', '二叉树', '分解问题的思路', '遍历的思路']
|
||||
tags: ['数据结构', '二叉树', '分解问题的思路', '遍历的思路', '核心框架']
|
||||
---
|
||||
|
||||
<p align='center'>
|
||||
@ -376,7 +376,7 @@ List<Integer> preorderTraverse(TreeNode root) {
|
||||
|
||||
一个原因是**这个算法的复杂度不好把控**,比较依赖语言特性。
|
||||
|
||||
Java 的话无论 ArrayList 还是 LinkedList,`addAll` 方法的复杂度都是 O(N),所以总体的最坏时间复杂度会达到 O(N^2),除非你自己实现一个复杂度为 O(1) 的 `addAll` 方法,底层用链表的话并不是不可能。
|
||||
Java 的话无论 ArrayList 还是 LinkedList,`addAll` 方法的复杂度都是 O(N),所以总体的最坏时间复杂度会达到 O(N^2),除非你自己实现一个复杂度为 O(1) 的 `addAll` 方法,底层用链表的话是可以做到的,因为多条链表只要简单的指针操作就能连接起来。
|
||||
|
||||
当然,最主要的原因还是因为教科书上从来没有这么教过……
|
||||
|
||||
@ -454,7 +454,7 @@ int count(TreeNode root) {
|
||||
}
|
||||
```
|
||||
|
||||
这两个问题的根本区别在于:一个节点在第几层,你从根节点遍历过来的过程就能顺带记录;而以一个节点为根的整棵子树有多少个节点,你需要遍历完子树之后才能数清楚。
|
||||
**这两个问题的根本区别在于:一个节点在第几层,你从根节点遍历过来的过程就能顺带记录,用递归函数的参数就能传递下去;而以一个节点为根的整棵子树有多少个节点,你需要遍历完子树之后才能数清楚,然后通过递归函数的返回值拿到答案**。
|
||||
|
||||
结合这两个简单的问题,你品味一下后序位置的特点,只有后序位置才能通过返回值获取子树的信息。
|
||||
|
||||
|
Reference in New Issue
Block a user