03 2017 档案
FB面经Prepare: Email User
摘要:账号之间如果有公共email就连边,我觉得要用hashMap, 存(email, user) pair 如果当前user的某个email在hashMap里出现过,当时是user1, 就看user和user1是否connected,否的话就要union,根据Union Find Union Find
阅读全文
Lintcode: Nuts & Bolts Problem
摘要:Quick Sort Way: We can use quick sort technique to solve this. We represent nuts and bolts in character array for understanding the logic. Nuts repres
阅读全文
FB面经Prepare: Merge K sorted Array
摘要:跟Merge K sorted lists不同在于,从PQ里poll出来以后不知道下一个需要被加入PQ的是哪一个 所以需要写一个wrapper class
阅读全文
FB面经 Prepare: Count Unique Island
摘要:方法可以是记录每次新的岛屿搜索的路径,left,right,up,down, 作为标志是否相同的key,存hashset
阅读全文
FB面经Prepare: Bipartite a graph
摘要:这道题应该是how to bipartite a graph Taken from GeeksforGeeks Following is a simple algorithm to find out whether a given graph is Birpartite or not using B
阅读全文
FB面经 Prepare: LCA of Deepest Nodes in Binary Tree
摘要:Recursion: 返回的时候返回lca和depth,每个node如果有大于一个子节点的depth相同就返回这个node,如果有一个子节点depth更深就返回个子节点lca,这个o(n)就可以了 Iteration: tree的recursion换成iteration处理,一般用stack都能解决
阅读全文
FB面经 Prepare: K closest point to the origin
摘要:Based on bucket sort: Based on Quick Select 当然,还有的方法是维护一个size为k的最大堆
阅读全文
FB面经prepare: 3 Window Max Sum
摘要:Follow Up: 这个其实可以优化到O(n)时间。建从左端到每个下标的最大window数组,再建从右端到每个下标的最大window数组。再从左往右走一遍所有的size k window,将其和与上一步建的两个数组一起加起来。遍历一遍取最大值即可。
阅读全文
Leetcode: Encode and Decode TinyURL
摘要:1. 根据系统设计的Estimation of the amount of data we need to store for the next couple of years, 我们应需要6位Base62的char来encode 2. assume 避免地址爆炸,相同的longUrl得到相同的sh
阅读全文