03 2017 档案

摘要:这是一道典型的拓扑问题。所以我们可以根据拓扑模型来完成这道题。这里面我们需要知道每个课程的入度和每个课程修完后可以解锁的课程。在这里需要注意的是因为课程从0到n-1,所以直接用index就可以做Key,不需要用到hash。这道题因为使用了入读,所以不用分级。因为入读已经帮我们把级分好。 阅读全文

posted @ 2017-03-21 12:34 codingEskimo 阅读(104) 评论(0) 推荐(0)

摘要:在写BFS的时候,经常会用到queue来标记需要验证的点(即由上一层而关联的各个点,就是所谓的灰色的点。黑色的点是queue最上面的那个点,就是正在被process会被poll出来那个)。然后辅助一个hash来记录是否已经visit过这个node。 阅读全文

posted @ 2017-03-17 11:45 codingEskimo 阅读(137) 评论(0) 推荐(0)

摘要:Useful Links for Explanation: http://www.programcreek.com/2012/12/leetcode-clone-graph-java/ http://www.cnblogs.com/springfor/p/3874591.html 这道题可以用BFS 阅读全文

posted @ 2017-03-17 11:40 codingEskimo 阅读(96) 评论(0) 推荐(0)

摘要:Very useful basic study material: http://blog.csdn.net/raphealguo/article/details/7523411 1. BFS The hard part is to define the level. Using int size 阅读全文

posted @ 2017-03-15 11:04 codingEskimo 阅读(106) 评论(0) 推荐(0)

摘要:Analysis: 1) 左子树是不是有LCA(A,B) 2) 右子树是不是有LCA(A,B) ==> A. 有 返回LCA(A,B) B. 没有 ==> b1) 如果有遇到A或者B, 返回A或B b2)没有遇到返回null 注意;要判断AB有没有遇到。 阅读全文

posted @ 2017-03-15 07:24 codingEskimo 阅读(122) 评论(0) 推荐(0)

摘要:这道题很简单,就是中序遍历,得到list然后valid数字排序即可 阅读全文

posted @ 2017-03-15 03:56 codingEskimo 阅读(104) 评论(0) 推荐(0)

摘要:Analysis 这个结果是用Divid & Conquer 做的 1. Divid: tree->left child and right child 2. Conquer: when it is null, return 0 3. Merge:如果是sequence, 则现在的sequence的 阅读全文

posted @ 2017-03-15 02:56 codingEskimo 阅读(90) 评论(0) 推荐(0)

摘要:Analysis: 这道题不难,但是我对于数结构以及递归掌握还是不够好,无法举一反三。 这道题要求所有的path,可以想到排列组合问题,所以可以套用排列组合模板。 但是因为这个是树结构,所以在套用的时候,要左右子树各走一遍。 这道题也是树的问题,用递归的时候要考虑三要素,递归的定义,递归的拆解,递归 阅读全文

posted @ 2017-03-15 01:22 codingEskimo 阅读(147) 评论(0) 推荐(0)

摘要:Good reference for all tree problem https://sites.google.com/site/jennyshelloworld/company-blog/chapter-3 binary-tree-divide-conquer Analysis: Here we 阅读全文

posted @ 2017-03-12 02:48 codingEskimo 阅读(109) 评论(0) 推荐(0)

摘要:1. Recursive Straight Forward, left -> right -> root 2. Iterator This is a little bit hard to understand, here is good reference https://sites.google. 阅读全文

posted @ 2017-03-12 02:20 codingEskimo 阅读(105) 评论(0) 推荐(0)

摘要:1. Recursive Straight Forward, Add left -> root -> right 2. Iterator 1. Create a node to present current node. 2. If current node is not null and stac 阅读全文

posted @ 2017-03-12 01:54 codingEskimo 阅读(105) 评论(0) 推荐(0)

摘要:1. Recursive: Very Straight forward, If the node is not null, add root -> traversal left -> traversal right 2. Iterator(find a very good explanation h 阅读全文

posted @ 2017-03-12 01:30 codingEskimo 阅读(117) 评论(0) 推荐(0)

摘要:Notice 1. Input String always need to be check whether it is NULL; 2. For the conner cases, source is shorter than the target or target is empty, it c 阅读全文

posted @ 2017-03-12 00:55 codingEskimo 阅读(153) 评论(0) 推荐(0)

导航