2015年5月16日

摘要: 题目: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 @ 2015-05-16 23:57 承续缘 阅读(287) 评论(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... 阅读全文
posted @ 2015-05-16 23:09 承续缘 阅读(142) 评论(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 @ 2015-05-16 21:53 承续缘 阅读(192) 评论(0) 推荐(0) 编辑
摘要: 题目:Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.代码:/** * Definition for singly-linked ... 阅读全文
posted @ 2015-05-16 21:23 承续缘 阅读(159) 评论(0) 推荐(0) 编辑
摘要: 题目:Given an array where elements are sorted in ascending order, convert it to a height balanced BST.代码:/** * Definition for a binary tree node. * stru... 阅读全文
posted @ 2015-05-16 20:13 承续缘 阅读(192) 评论(0) 推荐(0) 编辑
摘要: 题目:Given a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of a node contains onl... 阅读全文
posted @ 2015-05-16 18:15 承续缘 阅读(196) 评论(0) 推荐(0) 编辑
摘要: 题目:Givenn, generate all structurally uniqueBST's(binary search trees) that store values 1...n.For example,Givenn= 3, your program should return all 5 ... 阅读全文
posted @ 2015-05-16 16:56 承续缘 阅读(212) 评论(0) 推荐(0) 编辑
摘要: 题目:Givenn, how many structurally uniqueBST's(binary search trees) that store values 1...n?For example,Givenn= 3, there are a total of 5 unique BST's. ... 阅读全文
posted @ 2015-05-16 15:38 承续缘 阅读(220) 评论(0) 推荐(0) 编辑
摘要: 题目:Given inorder and postorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.代码:/** * De... 阅读全文
posted @ 2015-05-16 11:43 承续缘 阅读(153) 评论(0) 推荐(0) 编辑
摘要: 题目:Given preorder and inorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.代码:/** * Def... 阅读全文
posted @ 2015-05-16 11:14 承续缘 阅读(143) 评论(0) 推荐(0) 编辑

导航