摘要: 题目:Given a binary tree, return thebottom-up level ordertraversal of its nodes' values. (ie, from left to right, level by level from leaf to root).For ... 阅读全文
posted @ 2014-05-14 16:59 ThreeMonkey 阅读(147) 评论(0) 推荐(0) 编辑
摘要: 题目:Given an array where elements are sorted in ascending order, convert it to a height balanced BST.解题思路:同链表的方法一样。一分为二,递归进行求解。代码: 1 /** 2 * Definitio... 阅读全文
posted @ 2014-05-14 16:49 ThreeMonkey 阅读(127) 评论(0) 推荐(0) 编辑
摘要: 题目:Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.解题思路:注意是让构造平衡二叉搜索树。每次将链表从中间断开,分成左右两部分。... 阅读全文
posted @ 2014-05-14 16:46 ThreeMonkey 阅读(129) 评论(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 de... 阅读全文
posted @ 2014-05-14 16:42 ThreeMonkey 阅读(112) 评论(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... 阅读全文
posted @ 2014-05-14 16:25 ThreeMonkey 阅读(132) 评论(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... 阅读全文
posted @ 2014-05-14 16:22 ThreeMonkey 阅读(109) 评论(0) 推荐(0) 编辑
摘要: 题目:Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.For example:Given the below binary tree andsu... 阅读全文
posted @ 2014-05-14 16:18 ThreeMonkey 阅读(157) 评论(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 @ 2014-05-14 16:15 ThreeMonkey 阅读(121) 评论(0) 推荐(0) 编辑
摘要: 题目:Given a stringSand a stringT, count the number of distinct subsequences ofTinS.A subsequence of a string is a new string which is formed from the o... 阅读全文
posted @ 2014-05-14 16:03 ThreeMonkey 阅读(140) 评论(0) 推荐(0) 编辑
摘要: 题目:Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; }Populate each next poi... 阅读全文
posted @ 2014-05-14 15:54 ThreeMonkey 阅读(151) 评论(0) 推荐(0) 编辑