摘要: 题目:Given acompletebinary tree, count the number of nodes.Definition of a complete binary tree fromWikipedia:In a complete binary tree every level, exc... 阅读全文
posted @ 2015-08-31 05:18 Hygeia 阅读(278) 评论(0) 推荐(0) 编辑
摘要: 题目:Given a binary tree, return all root-to-leaf paths.For example, given the following binary tree: 1 / \2 3 \ 5All root-to-leaf paths are:["... 阅读全文
posted @ 2015-08-31 02:48 Hygeia 阅读(153) 评论(0) 推荐(0) 编辑
摘要: 题目:Invert a binary tree. 4 / \ 2 7 / \ / \1 3 6 9to 4 / \ 7 2 / \ / \9 6 3 1代码: 1 public TreeNode invertTree... 阅读全文
posted @ 2015-08-31 02:11 Hygeia 阅读(144) 评论(0) 推荐(0) 编辑
摘要: 题目:Given a binary search tree, write a functionkthSmallestto find thekth smallest element in it.Note:You may assume k is always valid, 1 ≤ k ≤ BST's t... 阅读全文
posted @ 2015-08-31 01:05 Hygeia 阅读(187) 评论(0) 推荐(0) 编辑
摘要: Given the root and two nodes in a Binary Tree. Find the lowest common ancestor(LCA) of the two nodes. The lowest common ancestor is the node with larg 阅读全文
posted @ 2015-08-31 00:59 Hygeia 阅读(231) 评论(0) 推荐(0) 编辑