随笔分类 - online judge:LeetCode--树
摘要:/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), r
阅读全文
摘要:Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum. N
阅读全文
摘要:Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary tree is defined as: a binary tree in which the dep
阅读全文
摘要:Given a n-ary 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 le
阅读全文
摘要: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 l
阅读全文
摘要:100. Same Tree 100. Same Tree Given two binary trees, write a function to check if they are the same or not. Two binary trees are considered the same
阅读全文
摘要:108. Convert Sorted Array to Binary Search Tree 108. Convert Sorted Array to Binary Search Tree Given an array where elements are sorted in ascending
阅读全文
摘要:538. Convert BST to Greater Tree 538. Convert BST to Greater Tree Given a Binary Search Tree (BST), convert it to a Greater Tree such that every key o
阅读全文
摘要:993. Cousins in Binary Tree 993. Cousins in Binary Tree In a binary tree, the root node is at depth 0, and children of each depth knode are at depth k
阅读全文
摘要:637. Average of Levels in Binary Tree 637. Average of Levels in Binary Tree Given a non-empty binary tree, return the average value of the nodes on ea
阅读全文
摘要:965. Univalued Binary Tree 965. Univalued Binary Tree A binary tree is univalued if every node in the tree has the same value. Return true if and only
阅读全文
摘要:938. Range Sum of BST Given the root node of a binary search tree, return the sum of values of all nodes with value between L and R (inclusive). The b
阅读全文