avatar
amazonLocal 组 面经# JobHunting - 待字闺中
m*k
1
amazonLocal 组,
上上周3面的,本周2收到据信,攒人品,上面经。
印女,PM,
1. copy linked list with random link in each node. 我给的答案不是回家后
google到的那个big linklist then separate, 我让原node的random link point to
its clone。
这样也能达到要求但改变了原始link,她也没反对。
2. code IsBST,
我写了个递归,还需要看root结点是否大于left child's subtree max, 以及是否小于
right child's subtree min, 被她问到复杂度, 指出非最优,重新想了一会, 说那
就inorder traversal , 每次和前一个值比一下,先给一个Prev=-infinity, 在白板上
纠结了一阵写出了和http://www.mitbbs.com/article/JobHunting/31990685_3.html相似的code.不过我是把prev传入IsBST,而且用
prev = +infinity 来表示false; 还是Kramnik (克拉姆尼克)的更graceful, 兄弟你咋
不早点贴出来啊,hehe!
3. customers want to buy some products but the products are out of stock,
design a system to notify them when those products are again available.
我回答说这就是个小功能,建立一个 wishList table with 2 columns, prodId 和
customerIDs 每次货物到库重新录入系统时 retrieve wishList table by productId
, 然后给粗customer 发信。但她好像不满意,强调说要设计一个
系统来实现。我傻了一会,又说可以在数据库中加一个trigger,一旦product 数目从0
update 到正值就给信. 她好像还是不满意。 后来想,难道她想听JMS?
白男,自报是director,
spend quite some time talking about my background and his team.
1.implement priority queue, 我回答用hashmap, key is priority level, value
is a normal queue, 这个非主流自创和上网看到的post(http://www.java-forums.org/java-lang/7449-how-implement-priority-queue-java.html)简直大相庭径, 表砸我,hoho!
2.design, display a customer's friends list who also bought the product he
is curently looking at.
小白男,
1. storeLocator, 100 stores, find the closest k=5 to customer's location. max-heap.
2. based on 1, given MaxHeap interface, implement
specified methods.
3. design deck, card classes.
小印男,
1. implement LRU cache , 我说可以用java的LinkedHashMap, 或者自己用 hashMap +
double linked list.
2. how to improve a web app. 我先draw a graph from browser to App server and DB, 然后每个环节侃了一通。
3. stock history data int stock[n], find the best sell and buy time.
O(n) ,
int maxgain =0, best_buytime = 0, best_selltime =0; current_buytime=0;
current_selltime =0;
for( i = 1 to stock.length-1)
{
if (stock[i] > stock[current_selltime])
{
current_selltime = i ;
//update maxgain if possible
int current_gain = stock[current_selltime] - stock[current_buytime];
if(current_gain > maxgain)
{
maxgain = current_gain ;
best_selltime = current_selltime;
best_buytime = current_buytime;

}
}
if (stock[i] < stock[current_buytime])
{
current_selltime = i;
current_buytime = i;
}
}
也可以在stock array 尾部加一个dummy end node, stock[n+1] = -1,
这样就只需要在if (stock[i] < stock[current_buytime]) block 中 update
maxgain 和 best_*time.
总结,这些经典题应该烂熟于心,对于我这样的非牛人现场纠结地想和写基本等于死菜
。 :(
anyway, 谨以此文纪念又一次搞砸的面试。
avatar
S*0
2
很详细,多谢分享

to

【在 m*****k 的大作中提到】
: amazonLocal 组,
: 上上周3面的,本周2收到据信,攒人品,上面经。
: 印女,PM,
: 1. copy linked list with random link in each node. 我给的答案不是回家后
: google到的那个big linklist then separate, 我让原node的random link point to
: its clone。
: 这样也能达到要求但改变了原始link,她也没反对。
: 2. code IsBST,
: 我写了个递归,还需要看root结点是否大于left child's subtree max, 以及是否小于
: right child's subtree min, 被她问到复杂度, 指出非最优,重新想了一会, 说那

avatar
l*a
3
先顶后看

to

【在 m*****k 的大作中提到】
: amazonLocal 组,
: 上上周3面的,本周2收到据信,攒人品,上面经。
: 印女,PM,
: 1. copy linked list with random link in each node. 我给的答案不是回家后
: google到的那个big linklist then separate, 我让原node的random link point to
: its clone。
: 这样也能达到要求但改变了原始link,她也没反对。
: 2. code IsBST,
: 我写了个递归,还需要看root结点是否大于left child's subtree max, 以及是否小于
: right child's subtree min, 被她问到复杂度, 指出非最优,重新想了一会, 说那

avatar
n*w
4
1. copy linked list with random link in each node
意思是每个node里边多了一个variable,randomly 指向后面的某个node吧。
先复制成big linkedlist再separate的确不错。
不过也可以直接clone。clone的过程中,设置一个temporary array存node。如果clone
到某个node的时候,把temporary array中指向该node的设置好。
2. code IsBST
说的是带两个参数min max吧。
这题面试中也被问到过。用min max做的。而且进一步还要求用iterative 遍历写code。
3. customers want to buy some products but the products are out of stock,
design a system to notify them when those products are again available.
感觉是考ood设计,是典型的observer pattern。product设计成一个class,把要货的
customer注册到一个队列里。到货了通知队列中所有的customer。

to

【在 m*****k 的大作中提到】
: amazonLocal 组,
: 上上周3面的,本周2收到据信,攒人品,上面经。
: 印女,PM,
: 1. copy linked list with random link in each node. 我给的答案不是回家后
: google到的那个big linklist then separate, 我让原node的random link point to
: its clone。
: 这样也能达到要求但改变了原始link,她也没反对。
: 2. code IsBST,
: 我写了个递归,还需要看root结点是否大于left child's subtree max, 以及是否小于
: right child's subtree min, 被她问到复杂度, 指出非最优,重新想了一会, 说那

avatar
f*t
5
感谢分享。都是经典题啊,onsite就这难度?
avatar
y*g
6
。。。。难度高不高在于面试官怎么看
fb的题目难度还不如这个呢,但要求bug free

【在 f*******t 的大作中提到】
: 感谢分享。都是经典题啊,onsite就这难度?
avatar
f*t
7
其实要求bug free才是最难的
最简单的binary search都估计没几个人能一遍写对

【在 y*******g 的大作中提到】
: 。。。。难度高不高在于面试官怎么看
: fb的题目难度还不如这个呢,但要求bug free

avatar
y*g
8
所以这种难度就够了,

【在 f*******t 的大作中提到】
: 其实要求bug free才是最难的
: 最简单的binary search都估计没几个人能一遍写对

avatar
q*x
9
copy linked list with random link in each node.
我让原node的random link point to its clone。 这样也能达到要求但改变了原始link,她
也没反对。
没看懂。你怎么知道哪些node的random link指向正在复制的node?
楼主自感哪里答不好?

to

【在 m*****k 的大作中提到】
: amazonLocal 组,
: 上上周3面的,本周2收到据信,攒人品,上面经。
: 印女,PM,
: 1. copy linked list with random link in each node. 我给的答案不是回家后
: google到的那个big linklist then separate, 我让原node的random link point to
: its clone。
: 这样也能达到要求但改变了原始link,她也没反对。
: 2. code IsBST,
: 我写了个递归,还需要看root结点是否大于left child's subtree max, 以及是否小于
: right child's subtree min, 被她问到复杂度, 指出非最优,重新想了一会, 说那

avatar
a*n
10
同问,这些都是经典题。会不会你思路出来太快,让人觉得你背题目啊。如果都答上来
没理由没offer啊。。。。
avatar
s*y
11
感觉有点偏难。LZ既然知道heap,为什么要用hash map实现priority Q, 过于非主流了.
..
avatar
q*x
12
小白ok。三妹偏难。设计题有点多。

了.

【在 s********y 的大作中提到】
: 感觉有点偏难。LZ既然知道heap,为什么要用hash map实现priority Q, 过于非主流了.
: ..

avatar
A*u
13
非常感谢
这个版就是牛啊
我才潜水1个多星期,就发现 1,2已经讨论过了.

to

【在 m*****k 的大作中提到】
: amazonLocal 组,
: 上上周3面的,本周2收到据信,攒人品,上面经。
: 印女,PM,
: 1. copy linked list with random link in each node. 我给的答案不是回家后
: google到的那个big linklist then separate, 我让原node的random link point to
: its clone。
: 这样也能达到要求但改变了原始link,她也没反对。
: 2. code IsBST,
: 我写了个递归,还需要看root结点是否大于left child's subtree max, 以及是否小于
: right child's subtree min, 被她问到复杂度, 指出非最优,重新想了一会, 说那

avatar
q*8
14
感谢楼主啊。什么职位?new graduate?
avatar
A*u
15
IsBST
非递归,迭代怎么写
找到最后的,从后往上?

clone
code。

【在 n*******w 的大作中提到】
: 1. copy linked list with random link in each node
: 意思是每个node里边多了一个variable,randomly 指向后面的某个node吧。
: 先复制成big linkedlist再separate的确不错。
: 不过也可以直接clone。clone的过程中,设置一个temporary array存node。如果clone
: 到某个node的时候,把temporary array中指向该node的设置好。
: 2. code IsBST
: 说的是带两个参数min max吧。
: 这题面试中也被问到过。用min max做的。而且进一步还要求用iterative 遍历写code。
: 3. customers want to buy some products but the products are out of stock,
: design a system to notify them when those products are again available.

avatar
m*k
16
no job description, recruiter contacted then arranged local interview,
they flew here and interviewed quite some guys, for 2 days.

【在 q******8 的大作中提到】
: 感谢楼主啊。什么职位?new graduate?
avatar
m*k
17
originally I told her to use hashmap to remember the link between original
node and cloned node,
then she asked for no-extra-space solution, so
I came up with this:
each time after creating the clone node, change the original node's random
pointer to point to the clone. then after the whole linklist is cloned, traverse
again to update the random pointers.

link,她

【在 q****x 的大作中提到】
: copy linked list with random link in each node.
: 我让原node的random link point to its clone。 这样也能达到要求但改变了原始link,她
: 也没反对。
: 没看懂。你怎么知道哪些node的random link指向正在复制的node?
: 楼主自感哪里答不好?
:
: to

avatar
m*k
18
No
就是不够快啊!好一阵纠结才出来,还有一些被面试官指出后的更正,像股票那题,最
开始我都忘了remember best sell/buy time, only tracked maxgain, 傻透了!

【在 a*****n 的大作中提到】
: 同问,这些都是经典题。会不会你思路出来太快,让人觉得你背题目啊。如果都答上来
: 没理由没offer啊。。。。

avatar
m*k
19
骑驴找马。

【在 q******8 的大作中提到】
: 感谢楼主啊。什么职位?new graduate?
avatar
a*2
20
我也面了这个组,感觉面试题重复率相当高啊,是不是还问了很多behavior的问题

【在 m*****k 的大作中提到】
: No
: 就是不够快啊!好一阵纠结才出来,还有一些被面试官指出后的更正,像股票那题,最
: 开始我都忘了remember best sell/buy time, only tracked maxgain, 傻透了!

avatar
m*k
21
not at all.

【在 a**********2 的大作中提到】
: 我也面了这个组,感觉面试题重复率相当高啊,是不是还问了很多behavior的问题
avatar
m*k
23
大家回一下这几道design questions你们会如何回答吧。
avatar
s*n
24
能破坏原来数组,第一遍扫描建立cloneNode的时候,修改原数组的next指针指向新数
组,新数组的random指向老数组。这样第二遍的时候cloneNode->random = cloneNode-
>random->random->next;
这个题目蛋疼的利害,破坏原数组等同于利用O(N)的临时空间,都破坏原来数组了,还
clone干啥,直接返回原数组不就行了。

traverse

【在 m*****k 的大作中提到】
: originally I told her to use hashmap to remember the link between original
: node and cloned node,
: then she asked for no-extra-space solution, so
: I came up with this:
: each time after creating the clone node, change the original node's random
: pointer to point to the clone. then after the whole linklist is cloned, traverse
: again to update the random pointers.
:
: link,她

avatar
q*x
25
in case a copy is needed. the original one is broken but restored.

cloneNode-

【在 s******n 的大作中提到】
: 能破坏原来数组,第一遍扫描建立cloneNode的时候,修改原数组的next指针指向新数
: 组,新数组的random指向老数组。这样第二遍的时候cloneNode->random = cloneNode-
: >random->random->next;
: 这个题目蛋疼的利害,破坏原数组等同于利用O(N)的临时空间,都破坏原来数组了,还
: clone干啥,直接返回原数组不就行了。
:
: traverse

avatar
s*n
26
zkss恢复

【在 q****x 的大作中提到】
: in case a copy is needed. the original one is broken but restored.
:
: cloneNode-

avatar
q*8
27
product没有,然后available again再通知应该是observer pattern,比较典型。你先
说经典的pattern,然后讨论scalability的问题。比如load balancer,srever farm。
不知道是不是这个思路。
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。