摘要: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...
阅读全文
摘要: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...
阅读全文
摘要: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...
阅读全文
摘要: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...
阅读全文
摘要:首先呢 可能会想到用一个windows去放这些东西.可能会想到hashtable去. 但是hashtable 无法用Index去查询.abcabcbb. hashtable: abc 当第二个a来的时候, 我们想bca 貌似不好实现.这种情况就很像LRU. 用 node连接,用hashta...
阅读全文
摘要:http://leetcode.com/2011/07/lowest-common-ancestor-of-a-binary-tree-part-i.html两种思路:top-down bottom-up递归实现,递归里面可以添加小递归方法. n^2自己总结的万能思路首先1. top-down 还...
阅读全文