- 博客(11)
- 资源 (5)
- 收藏
- 关注
原创 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 219
原创 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 395
原创 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 218
原创 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 225
原创 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 256
原创 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 265
原创 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 322
原创 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 207
原创 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 295
原创 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 813
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人