臭咸鱼的缺氧瓶

快给我氧气!


  • Home

  • Tags

  • Categories

  • Archives

  • Search

LeetCode337打家劫舍III

Posted on 2020-07-30 | | Visitors:
Words count in article: 260 字 | Reading time ≈ 1 分
题目链接https://leetcode-cn.com/problems/house-robber-iii/ 题解 递归写法 这个思路似乎是错的(不过我提交后是在某一个测试用例是超时了),先把这份代码放这儿吧,后边补正确的解法 题目要求两个结点不能相连,这不等于隔层求和 12345678910 ...
Read more »

LeetCode124二叉树中的最大路径和

Posted on 2020-07-27 | | Visitors:
Words count in article: 503 字 | Reading time ≈ 2 分
题目链接https://leetcode-cn.com/problems/binary-tree-maximum-path-sum/ 题解 递归解法 路径:一条从树中任意结点出发,达到任意结点的序列。该路径至少包含一个结点,且不一定经过根结点。 这道题和LeetCode687最长同值路径和LeetC ...
Read more »

LeetCode687最长同值路径

Posted on 2020-07-27 | | Visitors:
Words count in article: 489 字 | Reading time ≈ 2 分
题目链接https://leetcode-cn.com/problems/longest-univalue-path/ 题解 这道题写了好久,然后参考了题解 递归解法 这道题和LeetCode543二叉树的直径(点击查看)非常相似,可以看一下 类似的题目还有LeetCode124(点击查看),非常相 ...
Read more »

LeetCode404左叶子之和

Posted on 2020-07-27 | | Visitors:
Words count in article: 271 字 | Reading time ≈ 1 分
题目链接https://leetcode-cn.com/problems/sum-of-left-leaves/ 题解 自己写的 递归解法 思路见代码注释 12345678910111213141516171819202122232425262728293031323334353637// Pro ...
Read more »

LeetCode111二叉树的最小深度

Posted on 2020-07-26 | | Visitors:
Words count in article: 406 字 | Reading time ≈ 2 分
题目链接https://leetcode-cn.com/problems/minimum-depth-of-binary-tree/ 题解一 递归解法 我写的 说明详见注释 12345678910111213141516171819202122232425262728293031323334353 ...
Read more »

LeetCode101对称二叉树

Posted on 2020-07-26 | | Visitors:
Words count in article: 251 字 | Reading time ≈ 1 分
题目链接https://leetcode-cn.com/problems/symmetric-tree/ 题解 我写的 递归解法 具体方法见代码注释 123456789101112131415161718192021222324252627282930313233343536373839// Pr ...
Read more »

LeetCode572另一个树的子树

Posted on 2020-07-26 | | Visitors:
Words count in article: 297 字 | Reading time ≈ 1 分
题目描述https://leetcode-cn.com/problems/subtree-of-another-tree/ 题解 我写的 两层DFS、双重DFS 其它题解一般也是这个思路 1234567891011121314151617181920212223242526272829303132 ...
Read more »

LeetCode437路径总和III

Posted on 2020-07-26 | | Visitors:
Words count in article: 538 字 | Reading time ≈ 2 分
题目链接https://leetcode-cn.com/problems/path-sum-iii/ 题解 两个DFS,两个DFS作用不一样 我写的,其它人的题解大概也是这个思路 这道题是昨天那道题(点击查看)的扩展,建议先看一下昨天那道题的题解二。 昨天那道题中的路径是根结点到叶子结点之间的 ...
Read more »

LeetCode112路径总和

Posted on 2020-07-25 | | Visitors:
Words count in article: 555 字 | Reading time ≈ 3 分
题目链接https://leetcode-cn.com/problems/path-sum/ 题解一 我自己写的 在dfs过程中要记录当前结点与根结点之间的距离,并且回溯时也需要更新该值 注意要求是叶子结点到根结点之间的距离 详细思路见代码注释 12345678910111213141516171 ...
Read more »

LeetCode617合并二叉树

Posted on 2020-07-25 | | Visitors:
Words count in article: 275 字 | Reading time ≈ 1 分
题目链接https://leetcode-cn.com/problems/merge-two-binary-trees/ 题解 递归解法 解法见代码注释 123456789101112131415161718192021222324252627282930313233343536373839404 ...
Read more »
1…141516…32
臭咸鱼

臭咸鱼

祝你天天开心啊!

316 posts
182 tags
RSS
Links
  • Road Wide's Blog
  • Chou Xianyu's CNBlog
© 2018 — 2021 臭咸鱼 | Site words total count: 289.4k
Powered by Hexo
|
Theme — NexT.Gemini v5.1.4
本站总访问量 次