摘要:
For example, the lowest common ancestor (LCA) of nodes 2 and 8 is 6. Another example is LCA of nodes 2 and 4 is 2, since a node can be a descendant of 阅读全文
posted @ 2019-03-15 15:40
MarkLeeBYR
阅读(105)
评论(0)
推荐(0)
摘要:
Solution1: class Solution { public TreeNode invertTree(TreeNode root) { if (root == null) return null; TreeNode tmp = root.left; root.left = invertTre 阅读全文
posted @ 2019-03-15 15:38
MarkLeeBYR
阅读(105)
评论(0)
推荐(0)
摘要:
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. F 阅读全文
posted @ 2019-03-15 15:33
MarkLeeBYR
阅读(95)
评论(0)
推荐(0)
摘要:
Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest l 阅读全文
posted @ 2019-03-15 15:32
MarkLeeBYR
阅读(82)
评论(0)
推荐(0)
摘要:
Given an array where elements are sorted in ascending order, convert it to a height balanced BST. class Solution { public TreeNode sortedArrayToBST(in 阅读全文
posted @ 2019-03-15 15:30
MarkLeeBYR
阅读(82)
评论(0)
推荐(0)
摘要:
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 dept 阅读全文
posted @ 2019-03-15 15:30
MarkLeeBYR
阅读(76)
评论(0)
推荐(0)
摘要:
Solution1:广度优先 class Solution { public List<List<Integer>> levelOrderBottom(TreeNode root) { Queue<TreeNode> q = new LinkedList<>(); List<List<Integer 阅读全文
posted @ 2019-03-15 15:29
MarkLeeBYR
阅读(79)
评论(0)
推荐(0)
摘要:
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 阅读全文
posted @ 2019-03-15 15:21
MarkLeeBYR
阅读(53)
评论(0)
推荐(0)
摘要:
Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). Solution1: class Solution { public boolean isSymmetric( 阅读全文
posted @ 2019-03-15 15:20
MarkLeeBYR
阅读(93)
评论(0)
推荐(0)
摘要:
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 a 阅读全文
posted @ 2019-03-15 15:17
MarkLeeBYR
阅读(90)
评论(0)
推荐(0)