08 2018 档案
摘要:题目链接 https://leetcode.com/problems/kth smallest element in a bst/description/ 题目描述 Given a binary search tree, write a function kthSmallest to find th
阅读全文
摘要:题目链接 https://leetcode.com/problems/convert sorted array to binary search tree/description/ 题目描述 Given an array where elements are sorted in ascending
阅读全文
摘要:题目链接 https://leetcode.com/problems/n ary tree postorder traversal/description/ 题目描述 Given an n ary tree, return the postorder traversal of its nodes'
阅读全文
摘要:题目链接 https://leetcode cn.com/problems/maximum depth of n ary tree/description/ 题目描述 给定一个N叉树,找到其最大深度。 最大深度是指从根节点到最远叶子节点的最长路径上的节点总数。 说明: 1. 树的深度不会超过 100
阅读全文
摘要:题目链接 https://leetcode cn.com/problems/binary tree postorder traversal/description/ 题目描述 给定一个二叉树,返回它的 后序 遍历。 示例: 进阶: 递归算法很简单,你可以通过迭代算法完成吗? 题解 后序遍历,使用一个
阅读全文
摘要:题目链接 https://leetcode cn.com/problems/binary tree inorder traversal/description/ 题目描述 给定一个二叉树,返回它的中序遍历 示例: 进阶: 递归算法很简单,你可以通过迭代算法完成吗? 题解 采用栈来遍历,一直遍历到最左
阅读全文
摘要:题目链接 https://leetcode cn.com/problems/binary tree pruning/description/ 题目描述 给定二叉树根结点 root ,此外树的每个结点的值要么是 0,要么是 1。 返回移除了所有不包含 1 的子树的原二叉树。 ( 节点 X 的子树为 X
阅读全文
摘要:题目链接 https://leetcode cn.com/problems/maximum depth of binary tree/description/ 题目描述 给定一个二叉树,找出其最大深度。 二叉树的深度为根节点到最远叶子节点的最长路径上的节点数。 说明: 叶子节点是指没有子节点的节点。
阅读全文
摘要:题目链接 https://leetcode cn.com/problems/merge two binary trees/description/ 题目描述 给定两个二叉树,想象当你将它们中的一个覆盖到另一个上时,两个二叉树的一些节点便会重叠。 你需要将他们合并为一个新的二叉树。合并的规则是如果两个
阅读全文
摘要:题目链接 https://leetcode cn.com/problems/invert binary tree/description/ 题目描述 翻转一颗二叉树 示例 输入: 输出: ` 题解 使用递归的方式来求解。需要注意的是,在翻转的过程中,注意保存树节点的一个副本,不然在后面的翻转中会存在
阅读全文
摘要:题目链接 https://leetcode cn.com/problems/maximum binary tree/description/ 题目描述 给定一个不含重复元素的整数数组。一个以此数组构建的最大二叉树定义如下: 1. 二叉树的根是数组中的最大元素。 2. 左子树是通过数组中最大值左边部分
阅读全文

浙公网安备 33010602011771号