
树
HuangHongkai_
这个作者很懒,什么都没留下…
展开
-
LeetCode 99. Recover Binary Search Tree (BST重建)
Two elements of a binary search tree (BST) are swapped by mistake.Recover the tree without changing its structure.Example 1:Input: [1,3,null,null,2] 1 / 3 \ 2Output: [3,1,null,null,2]...原创 2018-11-01 10:55:37 · 195 阅读 · 0 评论 -
LeetCode 124. Binary Tree Maximum Path Sum(树中最长路径和,递归)
Given a non-empty binary tree, find the maximum path sum.For this problem, a path is defined as any sequence of nodes from some starting node to any node in the tree along the parent-child connection...原创 2018-11-01 11:32:00 · 143 阅读 · 0 评论 -
LeetCode222. Count Complete Tree Nodes (完全二叉树节点计数技巧)
Given a complete binary tree, count the number of nodes.Note:Definition of a complete binary tree from Wikipedia:In a complete binary tree every level, except possibly the last, is completely fille...原创 2018-11-01 19:00:41 · 248 阅读 · 0 评论 -
LeetCode 687. Longest Univalue Path (dfs+bfs)
Given a binary tree, find the length of the longest path where each node in the path has the same value. This path may or may not pass through the root.Note: The length of path between two nodes is r...原创 2018-11-01 22:22:01 · 144 阅读 · 0 评论 -
LeetCode 95. Unique Binary Search Trees II (二叉搜索树计数,卡特兰数)
Given an integer n, generate all structurally unique BST’s (binary search trees) that store values 1 … n.Example:Input: 3Output:[ [1,null,3,2], [3,2,null,1], [3,1,null,null,2], [2,1,3], ...原创 2018-11-02 12:23:46 · 203 阅读 · 0 评论