随笔分类 -  Tree

find the deepest node in a binary tree
摘要:Find the deepest node in a binary tree:Example:A/ \B C/ \ / \D E F G\HReturn Node ‘H’public class test { //unsigned 2^32-1 so we need a long to ins... 阅读全文

posted @ 2014-10-15 02:49 brave_bo 阅读(160) 评论(0) 推荐(0)

Lowest Common Ancestor of a Binary Tree Part
摘要:bottom-uppackage test.ui;import java.util.HashSet;import java.util.Set;public class test { //unsigned 2^32-1 so we need a long to instead. pub... 阅读全文

posted @ 2014-10-12 05:51 brave_bo 阅读(164) 评论(0) 推荐(0)

Printing a Binary Tree in Level Orders
摘要:BFS:Is it possible that a solution exists using only one single queue? Yes, you bet. The single queue solution requires two extra counting variables w... 阅读全文

posted @ 2014-10-11 02:52 brave_bo 阅读(139) 评论(0) 推荐(0)

Symmetric Tree
摘要:Symmetric TreeGiven a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmetric... 阅读全文

posted @ 2014-10-02 03:20 brave_bo 阅读(148) 评论(0) 推荐(1)

Longest Substring Without Repeating Charactersdf
摘要:首先呢 可能会想到用一个windows去放这些东西.可能会想到hashtable去. 但是hashtable 无法用Index去查询.abcabcbb. hashtable: abc 当第二个a来的时候, 我们想bca 貌似不好实现.这种情况就很像LRU. 用 node连接,用hashta... 阅读全文

posted @ 2014-10-02 02:56 brave_bo 阅读(126) 评论(0) 推荐(0)

Tree 总结
摘要:http://leetcode.com/2011/07/lowest-common-ancestor-of-a-binary-tree-part-i.html两种思路:top-down bottom-up递归实现,递归里面可以添加小递归方法. n^2自己总结的万能思路首先1. top-down 还... 阅读全文

posted @ 2014-10-01 05:54 brave_bo 阅读(123) 评论(0) 推荐(0)

导航