XCodeCareerService 2017
Please Visit Our BBS: 1024BBS
Mock Interview
Algorithms
System Design
Spring Cloud
Blockchain
Lec 1: Task Scheduler & Hashing
Contents
- External Sort: sort file with 100GB through 4GB RAM
- Problems
- FB高频:Task Scheduler和变种
- General approach to answer OOD question
- Consistent Hashing
hashCode()
equals()
- Twitter OA: Hacking Time
Homework
Reading Materials
- Cassandra 3.x High Availability - Second Edition: Chapter 2 Sections:
- Hash table fundamentals
- Consistent hashing
Code
Lec 2
Contents
- Twitter OA
- Hacking Time
- Information Mask
- Algorithm
- FB高频:Given an integer array, find number of subsets that its sum of min and max is less than k
- RPC
- REST API
Homework
Reading Materials
Code
Lec 3
Contents
- Twitter OA
- Times Series Aggregation
- Kraken
- Apache Log Success Rates
- Algorithm
- TreeMap
- Singleton
Homework:
Reading Materials
Contents
Lec 4
Contents
- Algorithm
- Trie
- Twitter OA: Expression Tree
- 电面高频题: what to do when website becomes slow or database becomes slow
Homework
Reading Materials
Code
Lec 5: Random Sampling
Contents
- Facebook题目讲解
- Algorithm
- Reservoir Sampling原理
- FB 高频 Given an integer array, find number of subsets that its sum of min and max is less than k
- Valid Triangle Number
- LRU Cache
Homework
Code
Lec 6
Contents
Homework
- Gray Code: 判断两个byte number 是不是互为gray code. The gray code is a binary numeral system where two successive values differ in only one bit
- window sum: given k for size of window and integer array nums, return array sum that its element sum[i] is sum of nums[i ~ i + k - 1]. For example, int[] nums = {2,1,1,1,2,2,3,2,2,2} and int k = 3, return [4, 3, 4, 5, 7, 7, 7, 6]
- 给一个数组找这些数的最大公约数
- Round Robin: 一个处理器要处理一堆request,一次只能处理一条,每次执行一个任务最多执行时间q,接着执行等待着的下一个任务。若前一个任务没执行完则放到队尾,等待下一次执行。假设只要有任务开始以后cpu是不会空闲的,也就是说cpu开始后如果空闲了就说明没有任务了,另外Robin Round最后返回值是float。最终返回average wait time。
- Shorted job first:一个处理器要处理一堆request,一次只能处理一条,如果它有几个积压着的requests,它会先执行持续时间短的那个;对于持续时间相等的requests,先执行最早到达处理器的request。问平均每个request要等多久才能被处理。input:requestTimes[],每个request到达处理器的时间; durations[] 每个request要处理的持续时间。 两个数组是一一对应的,并已按requestTimes[] 从小到大排序过。
- Binary search tree minimum sum from root to leaf
- Day change(cell growth): int[] dayChange(int[] cells, int days), cells 数组,有8个元素,每天的变化情况是 当前位置 cell = (cell[i - 1] == cell[i + 1]) ? 0 : 1, 左右相等,当前位置为0, 不等为1, 默认 cells[0]左边 和cells[cells.length - 1]右边的位置元素都是0, 求days天后的变化.
Reading Materials:
Code
Lec 7: Union Find
Contents
- Union Find
- Algorithm
- Day Change
- Minimum Spanning Tree
- Five Scores
- Maximum Subtree of Average
Homework
- Day change(cell growth): int[] dayChange(int[] cells, int days), cells 数组,有8个元素,每天的变化情况是 当前位置 cell = (cell[i - 1] == cell[i + 1]) ? 0 : 1, 左右相等,当前位置为0, 不等为1, 默认 cells[0]左边 和cells[cells.length - 1]右边的位置元素都是0, 求days天后的变化.
- Minimum Spanning Tree
题目内容是这样的,给十几个城市供电,连接不同城市的花费不同,让花费最小同时连到所有的边。给出一系列connection类,里面是edge两端的城市名和它们之间的一个cost,找出要你挑一些边,把所有城市连接起来并且总花费最小。不能有环,最后所以城市要连成一个连通块。
不能的话输出空表,最后还要按城市名字排序输出,按照node1来排序,如果一样的话再排node2。 输入: {“Acity”,”Bcity”,1}
(“Acity”,”Ccity”,2} (“Bcity”,”Ccity”,3} 输出: (“Acity”,”Bcity”,1}
(“Acity”,”Ccity”,2} 补充一句,test case一共有6个。 - Five Scores
写好了一个叫Result的类,中文翻译成节点,题目是输入是一堆节点,节点里面有两个属性学生id和分数
保证每个学生至少会有5个分数,求每个人最高的5个分数的平均分。返回的是Map, key是id,value是每个人最高5个分数的平均分double是平均分。 - Maximum Subtree of Average
就是给一棵多叉树,表示公司内部的上下级关系。每个节点表示一个员工,节点包含的成员是他工作了几个月(int),以及一个下属数组(ArrayList)
目标就是找到一棵子树,满足:这棵子树所有节点的工作月数的平均数是所有子树中最大的。最后返回这棵子树的根节点
这题补充一点,返回的不能是叶子节点(因为叶子节点没有下属),一定要是一个有子节点的节点
Reading Materials
Code
Lec 8: Geospatial & DB
Contents
- Algorithm:
- Maximum Minimum Path
- Maze
- Geospatial题目分析:Geohashes, Quadtrees, Hilbert Curves
- SQL v.s NoSQL
Homework
- Maximum Minimum Path 给一个int[][]的matirx,对于一条从左上到右下的path pi,pi中的最小值是mi,求所有mi中的最大值。只能往下或右.
- Maze: 给个array,其中只有一格是9,其他格子是0或1,0表示此路不通,1表示可以走,判断从(0,0) 点开始上下左右移动能否找到这个是9的格子
Reading Materials
Code
Lec 9: NoSQL
Mock
Contents
- SQL v.s. NoSQL
- Inverted Index
- Algorithm
- Tree Traversal Iteratively
Homework
Reading Materials
Code
Lec 10: System Design
Contents
- System Design
- FB 系统设计题:Cache Update
- LinkedIn系统设计题:inverted index; term(key)和document ids(value) 的partition机制设计
- Algorithm
Homework
Reading Materials
Code
Lec 11
Contents
Homework
Code
Lec 12
Contents
- Google onsite对策分析
- Algorithm
- Duplicate Number
Homework
Code
Lec 13
Mock
Contents
- 2017年Google OA
- Algorithm
Homework