![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
树
xiaocong1990
这个作者很懒,什么都没留下…
展开
-
[leetcode]maximum-binary-tree 最大二叉树
【代码】[leetcode]maximum-binary-tree 最大二叉树。原创 2024-07-11 11:11:55 · 197 阅读 · 0 评论 -
[leetcode]minimum-absolute-difference-in-bst 二叉搜索树的最小绝对差
【代码】[leetcode]minimum-absolute-difference-in-bst 二叉搜索树的最小绝对差。原创 2024-07-01 18:23:55 · 180 阅读 · 0 评论 -
[leetcode]sum-of-left-leaves 左叶子之和
【代码】[leetcode]sum-of-left-leaves 左叶子之和。原创 2024-06-27 16:35:55 · 214 阅读 · 0 评论 -
[leetcode]k-th-smallest-in-lexicographical-order 字典序的第K小数字
【代码】[leetcode]k-th-smallest-in-lexicographical-order 字典序的第K小数字。原创 2024-06-26 18:37:53 · 260 阅读 · 0 评论 -
[leetcode]insert-into-a-binary-search-tree
【代码】[leetcode]insert-into-a-binary-search-tree。原创 2024-06-26 14:41:13 · 209 阅读 · 0 评论 -
[leetcode]binary-tree-right-side-view 二叉树右视图
【代码】[leetcode]binary-tree-right-side-view 二叉树右视图。原创 2024-06-21 10:05:47 · 104 阅读 · 0 评论 -
[leetcode]validate-binary-search-tree
【代码】[leetcode]validate-binary-search-tree。原创 2024-06-12 12:01:00 · 219 阅读 · 0 评论 -
[leetcode]110. Balanced Binary Tree
题目链接:https://leetcode.com/problems/balanced-binary-tree/Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in whi原创 2016-10-25 21:34:41 · 233 阅读 · 1 评论 -
[leetcode] 二叉树的锯齿层序遍历
【代码】[leetcode] 二叉树的锯齿层序遍历。原创 2024-06-11 13:57:23 · 202 阅读 · 0 评论 -
[leetcode]将二叉搜索树转化为排序的双向链表
【代码】[leetcode]将二叉搜索树转化为排序的双向链表。原创 2024-06-11 13:51:54 · 149 阅读 · 0 评论 -
[leetcode]check-completeness-of-a-binary-tree
【代码】[leetcode]check-completeness-of-a-binary-tree。原创 2024-06-11 13:37:23 · 193 阅读 · 0 评论 -
[leetcode]114. Flatten Binary Tree to Linked List
题目链接:https://leetcode.com/problems/flatten-binary-tree-to-linked-list/#/descriptionGiven a binary tree, flatten it to a linked list in-place.For example,Given 1 / \原创 2017-05-09 20:19:46 · 189 阅读 · 1 评论 -
[leetcode]226. Invert Binary Tree
题目链接:https://leetcode.com/problems/invert-binary-tree/Invert a binary tree.class Solution{ public: TreeNode * invertTree(TreeNode * root) {原创 2016-10-14 16:35:32 · 245 阅读 · 1 评论 -
[leetcode]79. Word Search
题目链接:https://leetcode.com/problems/word-search/#/descriptionGiven a 2D board and a word, find if the word exists in the grid.The word can be constructed from letters of sequentially adjacent ce...原创 2017-05-14 16:12:21 · 432 阅读 · 1 评论 -
[leetcode]binary-tree-level-order-traversal
【代码】[leetcode]binary-tree-level-order-traversal。原创 2024-05-04 11:42:17 · 129 阅读 · 0 评论 -
[leetcode]95. Unique Binary Search Trees II 不同的二叉搜索树 II
题目链接:https://leetcode.com/problems/unique-binary-search-trees-ii/#/descriptionGiven an integern, generate all structurally uniqueBST's(binary search trees) that store values 1...n.For exa原创 2017-05-22 11:47:55 · 243 阅读 · 1 评论 -
[leetcode]96. Unique Binary Search Trees 不同的二叉搜索树
题目链接:https://leetcode.com/problems/unique-binary-search-trees/Givenn, how many structurally uniqueBST's(binary search trees) that store values 1...n?For example,Givenn= 3, there are a原创 2017-02-01 22:40:10 · 194 阅读 · 1 评论 -
[leetcode]对称二叉树
给你一个二叉树的根节点。, 检查它是否轴对称。原创 2024-05-01 17:38:26 · 16 阅读 · 0 评论 -
[leetcode] B树是不是A树的子结构
tree2 与 tree1 的一个子树拥有相同的结构和节点值。即 6 - > 1。tree2 与 tree1 的一个子树没有相同的结构和节点值。的某个节点为根的子树具有。的某个节点为根的子树具有。原创 2024-04-27 13:17:51 · 242 阅读 · 3 评论 -
[leetcode] all-nodes-distance-k-in-binary-tree 二叉树中所有距离为 K 的结点
若将 target\textit{target}target 当作树的根结点,我们就能从 target\textit{target}target 出发,使用深度优先搜索去寻找与 target\textit{target}target 距离为 kkk 的所有结点,即深度为 kkk 的所有结点。由于输入的二叉树没有记录父结点,为此,我们从根结点 root\textit{root}root 出发,使用深度优先搜索遍历整棵树,同时用一个哈希表记录每个结点的父结点。的所有结点的值的列表。给定一个二叉树(具有根结点。原创 2024-04-10 20:23:41 · 342 阅读 · 0 评论 -
[leetcode]maximum-width-of-binary-tree 二叉树最大宽度
被定义为该层最左和最右的非空节点(即,两个端点)之间的长度。将这个二叉树视作与满二叉树结构相同,两端点间会出现一些延伸到这一层的。最大宽度出现在树的第 4 层,宽度为 7 (6,null,null,null,null,null,7)。最大宽度出现在树的第 3 层,宽度为 4 (5,3,null,9)。最大宽度出现在树的第 2 层,宽度为 2 (3,2)。题目数据保证答案将会在。给你一棵二叉树的根节点。原创 2024-04-10 16:45:10 · 273 阅读 · 0 评论 -
[leetcode]104. Maximum Depth of Binary Tree
class Solution{ public: int maxDepth(TreeNode * root) { if(root==NULL) return 0;原创 2016-10-14 09:20:53 · 195 阅读 · 1 评论 -
[leetcode]验证二叉树的前序序列化
链接:力扣序列化二叉树的一种方法是使用前序遍历。当我们遇到一个非空节点时,我们可以记录下这个节点的值。如果它是一个空节点,我们可以使用一个标记值记录,例如 #。 _9_ / \ 3 2 / \ / \4 1 # 6/ \ / \ / \# # # # # #例如,上面的二叉树可以被序列化为字符串 "9,3,4,#,#,1,#,#,2,#,6,#,#",其中 # 代表一个空节点。给定一串以逗号分隔的序列,验证它是否是正确的二...原创 2022-01-12 21:27:01 · 86 阅读 · 0 评论 -
[LeetCode] Convert Sorted Array to Binary Search Tree
Given an array where elements are sorted in ascending order, convert it to a height balanced BST.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the...原创 2020-04-04 16:23:43 · 151 阅读 · 0 评论 -
[LeetCode] 112. Path Sum
Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.Note:A leaf is a node with no children.Example:...原创 2020-03-22 21:03:28 · 156 阅读 · 0 评论 -
[LeetCode] Sum Root to Leaf Numbers
Given a binary tree containing digits from0-9only, each root-to-leaf path could represent a number.An example is the root-to-leaf path1->2->3which represents the number123.Find the tota...原创 2020-03-22 20:56:27 · 137 阅读 · 0 评论 -
[leetcode]745. Prefix and Suffix Search
链接:https://leetcode.com/problems/prefix-and-suffix-search/description/Given many words, words[i] has weight i.Design a class WordFilter that supports one function, WordFilter.f(String prefix, String s...原创 2018-05-31 16:56:20 · 253 阅读 · 0 评论 -
[今日头条]字典序
题目描述 给定整数n和m,将1到n的这n个整数按字典序排列之后,求其中的第m个数字。对于n = 11,m = 4,按字典序排列依次为1, 10, 11, 2, 3, 4, 5, 6, 7, 8, 9,因此第4个数字为2。 输入 输入仅包含两个整数n和m。 样例输入 11 4 ...原创 2018-10-04 22:47:44 · 409 阅读 · 0 评论 -
[lintcode]880. Construct Binary Tree from String
链接:http://www.lintcode.com/zh-cn/problem/construct-binary-tree-from-string/You need to construct a binary tree from a string consisting of parenthesis and integers.The whole input represents原创 2018-03-26 16:27:34 · 310 阅读 · 0 评论 -
[leetcode]508. Most Frequent Subtree Sum
题目链接:https://leetcode.com/problems/most-frequent-subtree-sum/#/descriptionGiven the root of a tree, you are asked to find the most frequent subtree sum. The subtree sum of a node is defined as t原创 2017-06-10 16:19:17 · 206 阅读 · 0 评论 -
[leetcode]212. Word Search II
链接:https://leetcode.com/problems/word-search-ii/description/Given a 2D board and a list of words from the dictionary, find all words in the board.Each word must be constructed from letters o...原创 2018-05-30 19:55:36 · 212 阅读 · 1 评论 -
[leetcode]834. Sum of Distances in Tree
链接:https://leetcode.com/problems/sum-of-distances-in-tree/description/An undirected, connected tree with N nodes labelled 0...N-1 and N-1 edges are given.The ith edge connects nodes edges[i][0] and ed...原创 2018-06-04 20:51:52 · 972 阅读 · 0 评论 -
[leetcode]106. Construct Binary Tree from Inorder and Postorder Traversal
题目链接:https://leetcode.com/problems/construct-binary-tree-from-inorder-and-postorder-traversal/#/descriptionGiven inorder and postorder traversal of a tree, construct the binary tree.Note:You原创 2017-07-26 14:18:27 · 172 阅读 · 0 评论 -
[leetcode]105. Construct Binary Tree from Preorder and Inorder Traversal
题目链接:https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-traversal/#/descriptionGiven preorder and inorder traversal of a tree, construct the binary tree.Note:You m原创 2017-07-26 13:57:12 · 199 阅读 · 0 评论 -
[leetcode]652. Find Duplicate Subtrees
题目链接:https://leetcode.com/problems/find-duplicate-subtrees/description/Given a binary tree, return all duplicate subtrees. For each kind of duplicate subtrees, you only need to return the ro原创 2017-07-30 20:50:31 · 1210 阅读 · 1 评论 -
[leetcode]501. Find Mode in Binary Search Tree
题目链接:https://leetcode.com/problems/find-mode-in-binary-search-tree/#/descriptionGiven a binary search tree (BST) with duplicates, find all the mode(s) (the most frequently occurred element)原创 2017-07-16 16:40:16 · 199 阅读 · 0 评论 -
[leetcode]543. Diameter of Binary Tree
题目链接:https://leetcode.com/problems/diameter-of-binary-tree/#/descriptionGiven a binary tree, you need to compute the length of the diameter of the tree. The diameter of a binary tree is the leng原创 2017-07-16 13:35:14 · 203 阅读 · 0 评论 -
[leetcode]109. Convert Sorted List to Binary Search Tree
题目链接:https://leetcode.com/problems/convert-sorted-list-to-binary-search-tree/#/descriptionGiven a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST原创 2017-06-12 12:06:38 · 210 阅读 · 0 评论 -
[leetcode]513. Find Bottom Left Tree Value
题目链接:https://leetcode.com/problems/find-bottom-left-tree-value/#/descriptionGiven a binary tree, find the leftmost value in the last row of the tree.Example 1:Input: 2 / \ 1原创 2017-06-10 15:52:11 · 174 阅读 · 0 评论 -
[leetcode]617. Merge Two Binary Trees
题目链接:https://leetcode.com/problems/merge-two-binary-trees/#/descriptionGiven two binary trees and imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped原创 2017-07-11 11:46:38 · 202 阅读 · 0 评论