
C++
文章平均质量分 67
haotiangg
这个作者很懒,什么都没留下…
展开
-
LeetCode 617. Merge Two Binary Trees (C++)
C++ solution for LeetCode 617. Merge Two Binary Trees. No extra node is created.原创 2017-06-20 22:03:43 · 842 阅读 · 0 评论 -
LeetCode 563. Binary Tree Tilt (C++)
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原创 2017-06-26 17:42:37 · 417 阅读 · 0 评论 -
LetCode 404. Sum of Left Leaves (C++)
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.原创 2017-06-26 16:57:18 · 243 阅读 · 0 评论 -
LeetCode 104. Maximum Depth of Binary Tree (C++)
Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.方法一: 深度有限遍历/** * Definition for a b原创 2017-06-22 00:04:55 · 290 阅读 · 0 评论 -
LeetCode 226. Invert Binary Tree (c++)
Invert a binary tree. 4 / \ 2 7 / \ / \1 3 6 9to 4 / \ 7 2 / \ / \9 6 3 1Trivia:This problem was inspired by this original tweet by Max Howell原创 2017-06-22 11:05:11 · 251 阅读 · 0 评论 -
LeetCode 508. Most Frequent Subtree Sum (c++)
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 (includi原创 2017-06-22 10:30:46 · 276 阅读 · 0 评论 -
LeetCode 538. Convert BST to Greater Tree (C++)
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.Exampl原创 2017-06-21 23:46:32 · 346 阅读 · 0 评论 -
LeetCode 515. Find Largest Value in Each Tree Row (C++)
You need to find the largest value in each row of a binary tree.Example:Input: 1 / \ 3 2 / \ \ 5 3 9 Output: [1, 3, 9]方法一:用vector + 2个标原创 2017-06-21 22:00:21 · 230 阅读 · 0 评论 -
LeetCode 513. Find Bottom Left Tree Value (C++)
Given a binary tree, find the leftmost value in the last row of the tree.Example 1:Input: 2 / \ 1 3Output:1Example 2: Input: 1 / \ 2 3原创 2017-06-21 13:57:15 · 323 阅读 · 0 评论 -
LeetCode 100. Same Tree (C++)
Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical and the nodes have the same value.思路:前序遍历,判断原创 2017-06-26 17:53:55 · 242 阅读 · 0 评论