电面1
1): find the largest number in an array, explain how?
很easy, 走一遍数组,update一下最大值。
follow up: so how many times of compare do you need?
很easy n-1。
2) Is there any chance fewer times of compare?
在想,说不用想了,没有。
3) can you find the number using divide + conquer/ recursion? write the code
不明白为什么非要recursion,
说因为优势文件很大,电脑一次只能阅读1000个数据。
于是开始写了一个1000限制的程序。
说不对,我的1000只是比如, 用类似merge的想法做。
写了出来。
4) are you OK with the above algorithm in reality?
我说如果只要最大的,可以。
说如果两个失败者,你能得到其他信息吗?
不能
5) how can you the find the second largest number using the same algorithm(recursion)?
不会,如果用quick select, heap 都很容易啊。
说必须就用这个类似recursion和 merge的算法。
思考中。
说提醒一下,用其他的数据结构可以
思考中,
提醒一下,你熟悉hashmap吗?
哦,熟悉,想。key是赢家,value是最大输家, 不停update最大输家。写了出来。
说,不好,如果 key是赢家,value是输家的list最好。
时间到。
电面2
白人,说我只能给你25分钟,写两个题,于是特别紧张。
写个任意树的数据结构, 再写个search(int val)的函数,返回一个节点。
解sudoku
问了5分钟research, 然后5分钟回答问题。
当天告诉下周可以来onsite了。
Onsite面
是个国人大哥, 人不在现场,Skype的。感觉大哥给的问题不算难。但自己还是太紧张了,而且交流不太好,代码写的一塌糊涂。
题目1: 给一棵二叉树, serialize成字符串,
题目2: 给一个字符串, deserialize成二叉树。
一个白人
题目: 一串灯泡,实现 flip(int i, int j), isOn(int i)两个函数, 自己想数据结构。followup 很多, hashmap, bitmap, tree 都用上了。
一个小印
题目: n个数字, 求所有(n-1)组合的乘积。followup很多, hashmap和dp都涉及了。
HR的非技术问题