摘要: Given inorder and postorder traversal of a tree, construct the binary tree.Note: You may assume that duplicates do not exist in the tree.clas... 阅读全文
posted @ 2016-03-09 16:37 背锅侠 阅读(166) 评论(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.class... 阅读全文
posted @ 2016-03-09 16:35 背锅侠 阅读(133) 评论(0) 推荐(0) 编辑
摘要: Given n, how many structurally unique BST’s (binary search trees) that store values 1…n?For example, Given n = 3, there are a total of 5 uniq... 阅读全文
posted @ 2016-03-09 15:50 背锅侠 阅读(141) 评论(0) 推荐(0) 编辑
摘要: 解决二叉树的很多问题的方案都是基于对二叉树的遍历。遍历二叉树的前序,中序,后序三大方法算是计算机科班学生必写代码了。其递归遍历是人人都能信手拈来,可是在手生时写出非递归遍历恐非易事。正因为并非易事,所以网上出现无数的介绍二叉树非递归遍历方法的文章。可是大家需要的真是那些非递归遍历代... 阅读全文
posted @ 2016-03-09 15:24 背锅侠 阅读(299) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree.According to the definition of LCA on Wikipedia: “T... 阅读全文
posted @ 2016-03-09 14:27 背锅侠 阅读(182) 评论(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 tre... 阅读全文
posted @ 2016-03-09 11:30 背锅侠 阅读(117) 评论(0) 推荐(0) 编辑