臭咸鱼的缺氧瓶

快给我氧气!


  • Home

  • Tags

  • Categories

  • Archives

  • Search

LeetCode669修剪二叉搜索树

Posted on 2020-08-01 | | Visitors:
Words count in article: 295 字 | Reading time ≈ 1 分
题目链接https://leetcode-cn.com/problems/trim-a-binary-search-tree/ 题解 递归解法 我看了题解写出来的,我分析题目的时候以为还要交换左右子树什么的……,其实不用 思路见代码注释 123456789101112131415161718192 ...
Read more »

LeetCode328奇偶链表

Posted on 2020-07-31 | | Visitors:
Words count in article: 387 字 | Reading time ≈ 2 分
题目链接https://leetcode-cn.com/problems/odd-even-linked-list/ 题解 我自己写的 思路是:首先建立两个链表(奇数号结点链表和偶数号结点链表),然后遍历整个链表并通过尾插法构造这两个链表,最后将偶数号结点链表连接到奇数号结点链表尾部即可。 时间复杂 ...
Read more »

LeetCode725分隔链表

Posted on 2020-07-31 | | Visitors:
Words count in article: 406 字 | Reading time ≈ 2 分
题目链接https://leetcode-cn.com/problems/split-linked-list-in-parts/ 题解 这题我做了好久 该题抽象出来的话,就是要将n个物体分成k组,要求每组物体数量的差异不超过1。 思路就是先均分成k组,每组n/k(忽略小数位)个元素,剩下了n%k个物 ...
Read more »

LeetCode234回文链表

Posted on 2020-07-31 | | Visitors:
Words count in article: 340 字 | Reading time ≈ 2 分
题目链接https://leetcode-cn.com/problems/palindrome-linked-list/ 题解一 将链表元素存入数组,然后从首尾遍历 注意如果是空链表,结果也是true 123456789101112131415161718192021222324252627282 ...
Read more »

LeetCode445两数相加II

Posted on 2020-07-31 | | Visitors:
Words count in article: 793 字 | Reading time ≈ 4 分
题目链接https://leetcode-cn.com/problems/add-two-numbers-ii/ 题解一 使用了栈,遍历链表把结点存入栈中,然后弹栈将结点相加,注意进位 自己写的思路,代码有些长,应该有递归解法 12345678910111213141516171819202122 ...
Read more »

LeetCode24两两交换链表中的结点

Posted on 2020-07-30 | | Visitors:
Words count in article: 237 字 | Reading time ≈ 1 分
题目链接https://leetcode-cn.com/problems/swap-nodes-in-pairs/ 题解 递归解法,我自己写的 要明确函数的功能 函数中需手动处理空链表和链表中只有1个结点的情况;多个结点时,先手动交换前两个结点,然后通过递归交换其它结点 1234567891011 ...
Read more »

LeetCode19删除链表的倒数第N个结点

Posted on 2020-07-30 | | Visitors:
Words count in article: 568 字 | Reading time ≈ 3 分
题目链接https://leetcode-cn.com/problems/remove-nth-node-from-end-of-list/ 题解一 双指针:一个“快”,一个“慢” 快指针先到达链表末尾 具体思路见代码及注释 123456789101112131415161718192021222 ...
Read more »

LeetCode513找树左下角的值

Posted on 2020-07-30 | | Visitors:
Words count in article: 496 字 | Reading time ≈ 2 分
题目链接https://leetcode-cn.com/problems/find-bottom-left-tree-value/ 题解一 层次遍历 求最后一层最左边的结点 我自己想的思路:层次遍历,保存每一层最左侧的结点,直到二叉树遍历结束 123456789101112131415161718 ...
Read more »

LeetCode637二叉树的层平均值

Posted on 2020-07-30 | | Visitors:
Words count in article: 332 字 | Reading time ≈ 2 分
题目链接https://leetcode-cn.com/problems/average-of-levels-in-binary-tree/ 题解思路和层次遍历(点击查看)一样,没什么区别。 123456789101112131415161718192021222324252627282930313 ...
Read more »

LeetCode671二叉树中第二小的结点

Posted on 2020-07-30 | | Visitors:
Words count in article: 959 字 | Reading time ≈ 4 分
题目链接https://leetcode-cn.com/problems/second-minimum-node-in-a-binary-tree/ 题解一 自己想的思路,只用了函数本身,没有用其它函数 根据题目给的下面2个条件,又因为树是递归结构,可得到:根结点、左子结点和右子结点中根结点是最小的 ...
Read more »
1…131415…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
本站总访问量 次