脸熟实习店面

2题

  1. Given a list of directory info, return all paths which are not redundant. A redundant path is one with the root already on the list.

Ex: Input: ["/a/b/c","/a/b","/d/e","/d"]
Output: ["/a/b" , “/d”]

https://leetcode.com/problems/find-duplicate-file-in-system/ 变种

  1. Given a number find the next number made out of a permutation of every digit in it.

https://leetcode.com/problems/next-permutation/ 变种

我也是两题

Question 1: https://leetcode.com/problems/divide-two-integers/

Question 2:
You are given a map where key is city and value is population. Write a method that returns a random city but randomness is weighted by population of city. Ex: if NYC is 8M and Dallas is 4M, then method should return NYC twice as much as Dallas.
类似 https://leetcode.com/problems/random-pick-with-weight/

感谢楼主分享。祝楼主好运。求问楼主,第一题楼主是怎么做的呢?我(超级学渣)用trie做的,但是做不对,想求楼主指点一二。谢谢楼主。感恩。

你说的是下面这题吗?

  1. Given a list of directory info, return all paths which are not redundant. A redundant path is one with the root already on the list.

Ex: Input: ["/a/b/c","/a/b","/d/e","/d"]
Output: ["/a/b" , “/d”]

https://leetcode.com/problems/find-duplicate-file-in-system/ 变种

嗯嗯,是的是的,这题我看了,可能我太钝了。。,木有发现两者联系啊,求指点,谢谢。

感觉可以按照length排序做成list,后面的只要从前面查是否有前缀相同就行了,有的话把redundant从 list 中删掉。用Trie有点overkill吧,至少写起来很麻烦。

哦哦,好的好的,我试试。谢谢。

我考了这道 https://leetcode.com/problems/expression-add-operators/

45min phone interview. Started with 5-10 min introduction and around 30-35min to code, followed by 3-5min for questions.

Question 1) Write a function that returns whether a list of strings is sorted given a specific alphabet.
words = [“cc”, “cb”, “bc”, “ac”]
alphabet = [‘c’, ‘b’, ‘a’]
Output: true
Similar to : https://leetcode.com/problems/verifying-an-alien-dictionary/
Follow up: How would you make this production ready code and how would you verify/test it i.e., since it is not possible to write all possible test cases, how would you go about it?

Question 2) Given a reasonably well balanced binary tree, implement an iterator that iterates over it in in-order fashion.
Note: Parent pointer does not exists

Asked Time and Space complexities for each of them.

朋友内推,今天刚面完,白人小哥,做VR engineering的。人很nice,聊了一下各自background就开始。

每一题都分析时间和空间复杂度,感觉reviewers很重视。

蠡口散武灵。followup是 A=[1,2,5,…100…,9199,…], B=[3,4,5,2]和A=[1,2,5,…100…,9199,…], B=[3,4,7…2991]分别怎么做。

Task schedule with cool down ti‍‌‌‌‌‌‍‍‍‍‍‌‍‌‌‍‍‍‌‌me. 不可排序 Followup: 问如果可以排序的话怎么做

结束后说这一轮非常好,过了。

我猜第一题的follow up的意思是给两个排序的array,然后用two pointer做而不是用hashtable做来减少空间复杂 …

我回答是用two pointers + binary search,小哥说可以,没让实现

结束完马上就说结果哦?

这一轮题目都准备过,直接秒了。reviewers直接说excellent! I will let you pass. 我觉得应该这一轮是过了

恭喜

楼主是不是第一轮表现比较惊喜,所以背靠背?其他的就要等一段时间有回复

提前约在一起面,所以才是背靠背,可能因为我时间比较紧吧,Time slots只给了他们3天,所以他们都安排背靠背的两轮

谢楼主分享,小白表示第二题follow up比原题容易==

是的,但我两题都有准备,所以还好

想问一下楼主 A=[1,2,3,…100…,9999,…], B=[1,4,5,9] 和 A=[1,2,3,…100…,9999,…], B=[1,4,7. …

第一个是B非常小,第二个是A/B都非常大,问你怎么处理

请问第二题是力寇 流耳伊嘛?

请问第二题是力寇 流耳伊嘛?

是的,followup是变体。

同求问第一题follow up,只想到都用双指针。在哪里用binary search呀

小哥没让我实现,只是说一下可能的解决方案,binary search是在中间区间很大的时候可以用,我是这么回答的,小哥认同,但可能会有其他更好的方法,求大佬回答。谢谢~~!