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.思路:前序遍历,判断
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
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.
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
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
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
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
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个标
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
LeetCode 617. Merge Two Binary Trees (C++) C++ solution for LeetCode 617. Merge Two Binary Trees. No extra node is created.