
LC-Tree
seven_-
这个作者很懒,什么都没留下…
展开
-
<medium>LeetCode Problem -- 508. Most Frequent Subtree Sum
描述:Given the root of a tree, you are asked to find the most frequent subtree sum. The subtree sum of a node is defined as the sum of all the node values formed by the subtree rooted at that node (inclu原创 2018-02-09 17:46:34 · 144 阅读 · 0 评论 -
<easy>LeetCode Problem -- 538. Convert BST to Greater Tree
描述:Given a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed to the original key plus sum of all keys greater than the original key in BST.Examp原创 2018-02-25 09:38:17 · 141 阅读 · 0 评论 -
<medium>LeetCode Problem -- 94. Binary Tree Inorder Traversal
描述: Given a binary tree, return the inorder traversal of its nodes’ values.For example: Given binary tree [1,null,2,3], tree: 1 \ 2 / 3分析:中序inorder遍历二叉树思路一:递归,递归写起来很简单class Solutio原创 2018-03-11 11:14:10 · 116 阅读 · 0 评论 -
<easy>LeetCode Problem -- 655. Print Binary Tree
描述:Print a binary tree in an m*n 2D string array following these rules:1.The row number m should be equal to the height of the given binary tree. 2.The column number n should always be an odd number.原创 2018-02-21 12:26:22 · 193 阅读 · 0 评论 -
<easy>LeetCode Problem -- 606. Construct String from Binary Tree
描述:You need to construct a string consists of parenthesis and integers from a binary tree with the preorder traversing way.The null node needs to be represented by empty parenthesis pair “()”. And you原创 2018-02-21 11:47:29 · 172 阅读 · 0 评论 -
<easy>LeetCode Problem -- 653. Two Sum IV - Input is a BST
描述:Given a Binary Search Tree and a target number, return true if there exist two elements in the BST such that their sum is equal to the given target.Example 1: Input: 5 / \ 3 6 / \ \原创 2018-02-19 14:40:27 · 188 阅读 · 0 评论 -
<easy>LeetCode Problem -- 226. Invert Binary Tree
描述:Invert a binary tree. 4 / \ 2 7 / \ / \1 3 6 9 to 4 / \ 7 2 / \ / \9 6 3 1分析:对一棵二叉树进行左右倒置。思路一:递归。class Solution {public: TreeNode* invertTre原创 2018-02-08 14:47:12 · 206 阅读 · 0 评论 -
<easy>LeetCode Problem -- 637. Average of Levels in Binary Tree
描述:Given a non-empty binary tree, return the average value of the nodes on each level in the form of an array.Example 1: Input: 3 / \ 9 20 / \ 15 7 Output:原创 2018-02-07 18:57:22 · 182 阅读 · 0 评论 -
<easy>LeetCode Problem -- 669. Trim a Binary Search Tree
描述:Given a binary search tree and the lowest and highest boundaries as L and R, trim the tree so that all its elements lies in [L, R] (R >= L). You might need to change the root of the tree, so the res原创 2018-02-06 15:59:41 · 262 阅读 · 0 评论 -
<easy>LeetCode Problem -- 617. Merge Two Binary Trees
描述:Given two binary trees and imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are not.You need to merge them into a new binary原创 2018-02-06 15:30:31 · 170 阅读 · 0 评论 -
<medium> Leetcode Problem -- 654. Maximum Binary Tree
Given an integer array with no duplicates. A maximum tree building on this array is defined as follow:1.The root is the maximum number in the array. 2.The left subtree is the maximum tree constructed原创 2018-02-06 14:52:28 · 178 阅读 · 0 评论 -
<easy>LeetCode Problem -- 563. Binary Tree Tilt
描述:Given a binary tree, return the tilt of the whole tree.The tilt of a tree node is defined as the absolute difference between the sum of all left subtree node values and the sum of all right subtree原创 2018-02-26 13:40:01 · 270 阅读 · 0 评论 -
<easy>LeetCode Problem -- 404. Sum of Left Leaves
描述:Find the sum of all left leaves in a given binary tree.Example: \ 3 / \ 9 20 / \ 15 7There are two left leaves in the binary tree, with values 9 and 15 respectively. Return 24.原创 2018-02-26 12:49:26 · 175 阅读 · 0 评论 -
<medium>LeetCode Problem -- 144. Binary Tree Preorder Traversal
描述: Given a binary tree, return the preorder traversal of its nodes’ values.For example: Given binary tree [1,null,2,3], tree: 1 \ 2 / 3return [1,2,3].分析:前序遍历二叉树。思路一:递...原创 2018-03-13 19:31:02 · 138 阅读 · 0 评论