摘要:
二叉搜索树——230. 二叉搜索树中第K小的元素 题目: 思路: 中序遍历+辅助计数,到k了就输出就行。 代码: class Solution { public: // 计数 int n=0; // 存放结果 int res; int kthSmallest(TreeNode* root, int 阅读全文
posted @ 2021-04-25 20:40
Originhhh
阅读(74)
评论(0)
推荐(0)
摘要:
二叉树——剑指 Offer 27. 二叉树的镜像 题目: 思路: 中序遍历,其实就是翻转二叉树。 代码: class Solution { public: TreeNode* mirrorTree(TreeNode* root) { if(!root) return NULL; // 前序遍历 中 阅读全文
posted @ 2021-04-25 20:10
Originhhh
阅读(43)
评论(0)
推荐(0)
摘要:
二叉树——662. 二叉树最大宽度 题目: 思路: 层序遍历+辅助队列,但是还有些小细节,参考题解后(https://leetcode-cn.com/problems/maximum-width-of-binary-tree/solution/cshuang-bai-de-yan-du-you-xi 阅读全文
posted @ 2021-04-25 20:00
Originhhh
阅读(136)
评论(0)
推荐(0)

浙公网安备 33010602011771号