谷歌onsite nyc

上周1去纽约面了谷歌onsite, hr在linked-in 找到的我,好像是4个月,1年半工作经验。

  1. 白妹,multi-thread scheduler design
  2. 亚洲哥,赛车R(reverse, speed =1), A( Accelerate, move and speed*=2 ), 给一个距离,算最短的string到达那个点。(“AAARAAARA” )
  3. 中国哥,每个人有score和min_salary asked,每个人必须同等对待(最低min_salary/score ratio 必须一样),问招k人最少的钱(此题比较麻烦,因为要考虑进来的人可能score 特别高导致总salary太高,也可能ratio太高,导致大家都必须给更多钱。
  4. 白哥,给一个coin set,找能买的所有价格的集合。应该是lc原题
  5. 白哥,一个indexed Binary tree(inordered traversal indexed), 给你一个index number, 假如11, 你要用head找到那个node; 变形,给你一个complete binary tree,找最后一个node(可以用刚刚的func)。

第一轮用的doubly-linklist, 第二轮跪,先用的greedy algorithm,后面发现错用DFS结合binary search,只说了解法,第三轮跪,没解出来,第四轮,给了提示才反应过来是原题,DFS解了,第五轮秒,logn。不过其实存在hashtable里面更容易点?但是面试官叫我直接search.

明天HC应该出结果了,应该跪了。面完的时候感觉还有机会,现在才觉得简直幼稚,想了想HC的pass rate,感觉凉凉.发个面筋回报他人…

楼主加油!第二题和第三题都是刷题网的hard题…扒幺扒和扒伍柒…

这几个题没做过原题真的挺难做出来
赛车题想了两天

R是原地不动只换方向,A是先按原来速度走然后最后speed*=2,也就是AAAA = 15,这时速度是16,RAA = -3此时速度是-4, 之类的

第二题赛车我这样想的:比如要到19,先RAAA走15,剩下4. 然后RA走3,剩下1。最后一个R。就是 RAAARAR

请问楼主可以详细解释一下第一题吗?

非常有帮助 祝楼主过HC

这个onsite难度略高啊

请问第四题,coin set每个硬币能用几次呢?

前阵子被Google 加面了,觉得其中两道题蛮有意思的 ,虽然过啦但是不打算去了 ,所以发出来一起讨论下 ,求点人品 ,感觉最近人品是不是不够用了 。。。。
这个是Kirkland Google 。。。

  1. 一个一维数据可以看成一个棋盘 ,其中有两种棋子 ,或者也可以有空格,
    第一种棋子是 L ,只可以向左走 ,
    第二种棋子是 R,只可以往右走 ,
    唯一的规则是 任何两个 L 和 R 不可以交叉 , 比如 棋盘是 _ L _ _ _ R_ , 不可以走成 _ _ _ R L _ _ , 因为R 和L 交叉了

问题是 如果要是 一个棋盘的起始状态 比如, _ L _ L _ _ R _ _ R ,
和一个棋盘终止状态, _ _ L L R R _ _ _ _ ,
问起始状态有没有可能变成终止状态 。

直接贪心秒掉 ,面试小哥表示没见过这种解法 ,觉得有点意思 ,一看时间还多 ,就给了个followup

FollowUp :
如果要是每一个step 要求只能把某一个棋子移动一个格子 ,并且要L 走一步 ,R 走一步这样alternate 的走 ,如何解决 ?
比如 L_ _ R 可以变成 _ L R _ , 但是不可以变成 _ _ L R

依旧很简单我就不赘言了

  1. 一个二维数组表示一棵大树 (不是二叉树,就是一颗大树 。。。。) ,其中 0 表示空白 ,1 表示大树的一部分 , 问 ,我要是去掉一个1 的话 ,大树剩余部分是多少 。
    注意这里 ,去掉一个1 ,可能这个枝干就掉下去了 。

比如
0 0 1 1 1 1 1 1 1 1 0
0 0 0 0 1 0 1 0 0 0 0

我这里要是去掉 (0, 4) 位置的1 , 那么 (0,2) , (0,3)也就掉下去了 ,因为这两个点没办法链接到地板上了,也就作为一个树枝掉下去了 。

先给了个Brute Force ,然后给了个贪心的解法 ,貌似是最优解 ,面试官表示认可 。

1 Like

我也补充一个面经:

4 rounds of on-site technical interview, first three are just questions with solution patterns on leetcode, 2 medium and 1 easy. What I want to highlight and share here is the 4th round, which breaks my confidence.

Question:
You’re giving two strings source and target , write a function to determine if we could convert source to target .

Limits :

  • Both source and target are consisted with lower letters, which is a-z .
  • All available letters in converting are a-z , which means you can not convert one letter to 1 or # or others.

Converting rules:

  • In one convert operation, you can replace one value with another value , which means if there’re three letters with same value, you need to replace them together. For example, I have "abca" , now I can replace "a" to "d" , then it become "dbcd" . "dbca" is impossible !
  • You can do convert operation as many as you want.

How I feel:
I don’t know if I described clearly about the question, I’ve struggled about 20 minutes with the interviewer to clearify the question by talking (Now I realized that just asking the interviewer to paste the question is more efficient!). Then all I have was only 20 minutes (Because bath break, self introduction and environment setting cost 5 mins) to figure out the solution. It’s really hard to me, I’m thinking if there is a pattern to handle this but finally with interviewer’s hint (almost equals telling me the answer), I found it’s a un-pattern question and all it’s testing is how I think, not coding.
I would say that I performed well in all other sessions, but get bad feed back from this session, and finally rejected by the hiring committee.
I’m still in practicing, but I know the next time I meet questions like this, I can still not figure out the solution, but maybe I could perform better on communication and problem solving pattern(figure out all cases and write them down then try to solve one by one) to get the luck to earn a neutral feedback.

Solutions:

  1. Check corner cases, like null.
  2. Check the length.
  3. Check violations like "#" .
  4. Check if there exists mapping of one to multiple, like "aba""cde" where "a" maps to "c" and "e" . If so, return false.
  5. Check if all letters are used in target , if not then return true. Because we could use the un-used letter to convert each value one by one without affecting others.

Below are some examples:

Question: "ab""cd"
Answer: true
Solution: convert "a" to "c" then "b" to "d" , "ab""cb""cd"

Question: "aba""cde"
Answer: false
Solution: the first "a" and last "a" are always same, it’s impossible to make them one is "c" and the other is "e"

Question: "ab""ba"
Answer: true
Solution: convert "a" to "d" , then "b" to "a" , then "d" to "b" , "ab""db""da""ba"