上一页 1 ··· 21 22 23 24 25 26 27 28 29 ··· 33 下一页
摘要: 题目:Write a program to check whether a given number is an ugly number.Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For e... 阅读全文
posted @ 2015-09-02 06:51 Hygeia 阅读(162) 评论(0) 推荐(0) 编辑
摘要: 题目:Given a binary tree, flatten it to a linked list in-place.For example,Given 1 / \ 2 5 / \ \ 3 4 6The flattene... 阅读全文
posted @ 2015-09-01 07:26 Hygeia 阅读(158) 评论(0) 推荐(0) 编辑
摘要: Given an array where elements are sorted in ascending order, convert it to a height balanced BST.Solution:If you would have to choose an array element... 阅读全文
posted @ 2015-09-01 07:09 Hygeia 阅读(140) 评论(0) 推荐(0) 编辑
摘要: 题目: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) 编辑
摘要: 题目:Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.AnalysisThis problem can be solved by using B... 阅读全文
posted @ 2015-08-30 11:20 Hygeia 阅读(147) 评论(0) 推荐(0) 编辑
摘要: 题目:Given a binary tree containing digits from0-9only, each root-to-leaf path could represent a number.An example is the root-to-leaf path1->2->3which ... 阅读全文
posted @ 2015-08-28 11:46 Hygeia 阅读(124) 评论(0) 推荐(0) 编辑
上一页 1 ··· 21 22 23 24 25 26 27 28 29 ··· 33 下一页