上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 18 下一页

2017年6月13日

摘要: This question is very important: 1) Serialization: a. Don't try to do all the things at once. The first step is to get a list of all the tree node. Th 阅读全文
posted @ 2017-06-13 08:42 codingEskimo 阅读(136) 评论(0) 推荐(0) 编辑

2017年6月7日

摘要: Note: This question is good summary for this kind of problem. 1) Once you get the root, loop through all the children. Get the max up/down/max from th 阅读全文
posted @ 2017-06-07 08:50 codingEskimo 阅读(101) 评论(0) 推荐(0) 编辑
摘要: Note: O(n) This question is the extension of the version one. The longest consecutive Sequence could be found in "Parent->Children" or "Children -> Pa 阅读全文
posted @ 2017-06-07 07:54 codingEskimo 阅读(108) 评论(0) 推荐(0) 编辑
摘要: /** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */ public class Solution { ... 阅读全文
posted @ 2017-06-07 06:22 codingEskimo 阅读(78) 评论(0) 推荐(0) 编辑
摘要: Note: This is question is very similar to LCA original. The only difference is that the node may not exist. So if the node is not exsit, of course the 阅读全文
posted @ 2017-06-07 05:45 codingEskimo 阅读(137) 评论(0) 推荐(0) 编辑

2017年6月6日

摘要: Note 这道题和一不同,给了一个Node向上回溯的可能,所以不需要recersive的找。因为之前的那个题不能回头,所以必须先到最下面(或者找的A和B)。这道题我们只需要把A和B的path记住就可以了,然后比较path中从root到A或者B,一直到开始不一样的时候停止,那个最后一个一样的就是LCA 阅读全文
posted @ 2017-06-06 11:27 codingEskimo 阅读(393) 评论(0) 推荐(0) 编辑

2017年6月2日

摘要: Note: // 在root为根的二叉树中找A,B的LCA: // 如果找到了就返回这个LCA // 如果只碰到A,就返回A // 如果只碰到B,就返回B // 如果都没有,就返回null Just consider relationship between left, right and root 阅读全文
posted @ 2017-06-02 08:03 codingEskimo 阅读(142) 评论(0) 推荐(0) 编辑
摘要: Note: It is easier to use divided conquer. As you can see, the question is just to add right to left's last. Here we care more about last then the top 阅读全文
posted @ 2017-06-02 06:54 codingEskimo 阅读(111) 评论(0) 推荐(0) 编辑
摘要: Node: Quick Select: Avg O(N) Thought: put all the element less(more) than pivot to the first part, the rest to the second part. And Kth only falls to 阅读全文
posted @ 2017-06-02 06:09 codingEskimo 阅读(109) 评论(0) 推荐(0) 编辑

2017年6月1日

摘要: Important: using a/b < c/d => a*d < c*b to check, we don't need to do the type transfer For the tree, if we need to get the max/min tree node, it is b 阅读全文
posted @ 2017-06-01 08:29 codingEskimo 阅读(84) 评论(0) 推荐(0) 编辑
上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 18 下一页

导航