由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - Amazon onsite 面经
相关主题
Java 面试关于map 和setG家实习电面总结
问phone address book designleetcode 上单链表转BST那道题求指导
hash_map 的遍历问题狗狗家onsite面经
请教一个新鲜算法面试题感觉Binary Tree Postorder Traversal的iterative是三种traversal中最难的
最近变硬那家的面经G的一道考题
今天面试惨败,分享面经谁能给个Serialization/Deserialization of a Binary Tree Java版完整code?
讨论Amazon的一道题:根节点到叶节点之间最小和,并打印路径FB 面经
c语言实现TreeFeeyahoo onsite
相关话题的讨论汇总
话题: treenode话题: hashset话题: counting话题: person话题: hashmap
进入JobHunting版参与讨论
1 (共1页)
h**********d
发帖数: 4313
1
加recruiter一共6人
4个白男,午饭是一个组的经理 像是 土耳其/印度? 人
除了最后一个都比较nice
另外每个人有时间都问一遍我RA做的项目,说到想吐
1. java keyword
实现浮点数的平方根,经提醒搞出来了。要考虑小于1的特殊情况; 还要想time
complexity,相对于小数点后精确位数算如何时间复杂度
2. paint fill (toggle)。关键是要考虑space complexity,主要是method stack实时
一共有多少
说了组里的相关一个问题,大概说说TRIE,有一个improvement方法不好答,他说的
用一个计算load balance function,我吐
午饭是其中一个经理,详细讲了下组里的东西,基本和我做的有点相关,感觉他们招人还是很看背景的
3. 给一个数据结构数组,(parent, child), 重建二叉数,总是先遇见leftchild,
再遇见right child,假设输入没有问题。要求返回root。需要keep track of root,
最后用了一个hashset + 一个hashmap
说说怎么设计card class和deck class,各有哪些函数,什么时候static什么时候private,什么时候有返回,什么情况不返回
4. 如果要死就死这个geek手里了
一开始问了一堆behaivior question,比较tough
一道joseph problem题,但他说每次是1-based index 死,经典题目是0-based
,所以我code (单向circular链表)的里有一个bug。脑子已经不太转了,他说是当k
= 1的时候。 最后在最前面加上 if k ==1, return n...
这人看起来就是个geek中的geek,我刚写完他就说有一个bug。他说他见过一个最好的解法,用一个circular buffer,什么每次走到k的位置就不放在最后面。。。没明白这解法有什么好的
回来后想来想去最后一个人可能是bar raiser。。。求祝福和包子安慰。。
i**9
发帖数: 351
2
谢谢分享,能问一下是什么组吗
h**********d
发帖数: 4313
3
pm你了

【在 i**9 的大作中提到】
: 谢谢分享,能问一下是什么组吗
i**9
发帖数: 351
4
bar raiser可能就是challenge candidate的,让人觉得比较tough,祝一举拿下offer!
g*****e
发帖数: 3417
5
bless
你的题目我感觉比看到的其他a面筋要难一点
r*******e
发帖数: 7583
6
bless早日拿到offer

人还是很看背景的
,
候private,什么时候有返回,什么情况不返回
k
的解法,用一个circular buffer,什么每次走到k的位置就不放在最后面。。。没明白
这解法有什么好的

【在 h**********d 的大作中提到】
: 加recruiter一共6人
: 4个白男,午饭是一个组的经理 像是 土耳其/印度? 人
: 除了最后一个都比较nice
: 另外每个人有时间都问一遍我RA做的项目,说到想吐
: 1. java keyword
: 实现浮点数的平方根,经提醒搞出来了。要考虑小于1的特殊情况; 还要想time
: complexity,相对于小数点后精确位数算如何时间复杂度
: 2. paint fill (toggle)。关键是要考虑space complexity,主要是method stack实时
: 一共有多少
: 说了组里的相关一个问题,大概说说TRIE,有一个improvement方法不好答,他说的

h**********d
发帖数: 4313
7
我觉得题目本身不算难,我看版上的难题都没问道。。。
但是他们就题目本身引申的东西我都没准备过,比如算sqrt float的精确度和时间复杂
度关系,还有paint fill的method stack,也可能是大家发面经的时候没提到这部分,
我从没仔细想过,其实也是自己平时太粗心了

【在 g*****e 的大作中提到】
: bless
: 你的题目我感觉比看到的其他a面筋要难一点

g*********s
发帖数: 1782
8
what is paint fill and what is method stack?

【在 h**********d 的大作中提到】
: 我觉得题目本身不算难,我看版上的难题都没问道。。。
: 但是他们就题目本身引申的东西我都没准备过,比如算sqrt float的精确度和时间复杂
: 度关系,还有paint fill的method stack,也可能是大家发面经的时候没提到这部分,
: 我从没仔细想过,其实也是自己平时太粗心了

g**e
发帖数: 6127
9
让我想起了quake3里面那个神奇的inverse sqrt算法,呵呵
牛顿方法里复杂度和精度的关系,不看真的不容易想到。
http://en.citizendium.org/wiki/Newton's_method#Computation

【在 h**********d 的大作中提到】
: 我觉得题目本身不算难,我看版上的难题都没问道。。。
: 但是他们就题目本身引申的东西我都没准备过,比如算sqrt float的精确度和时间复杂
: 度关系,还有paint fill的method stack,也可能是大家发面经的时候没提到这部分,
: 我从没仔细想过,其实也是自己平时太粗心了

g**e
发帖数: 6127
10
重新再学习一下
float Q_rsqrt( float number )
{
long i;
float x2, y;
const float threehalfs = 1.5F;
x2 = number * 0.5F;
y = number;
i = * ( long * ) &y; // evil floating point bit level hacking
i = 0x5f3759df - ( i >> 1 ); // what the fuck?
y = * ( float * ) &i;
y = y * ( threehalfs - ( x2 * y * y ) ); // 1st iteration
// y = y * ( threehalfs - ( x2 * y * y ) ); // 2nd iteration, this can
be removed
#ifndef Q3_VM
#ifdef __linux__
assert( !isnan(y) ); // bk010122 - FPE?
#endif
#endif
return y;
}

【在 g**e 的大作中提到】
: 让我想起了quake3里面那个神奇的inverse sqrt算法,呵呵
: 牛顿方法里复杂度和精度的关系,不看真的不容易想到。
: http://en.citizendium.org/wiki/Newton's_method#Computation

相关主题
今天面试惨败,分享面经G家实习电面总结
讨论Amazon的一道题:根节点到叶节点之间最小和,并打印路径leetcode 上单链表转BST那道题求指导
c语言实现TreeFee狗狗家onsite面经
进入JobHunting版参与讨论
g*****e
发帖数: 3417
11
我觉得跟其他人发的amazon的coding题比起来,你的更麻烦些,当然我比较菜了...
相比g和f,当然这些题还是比较常见或者可以马上有idea的.
ps,据我所知bar raiser不光是challenge candidate,如果丫不让人过的话其他人都过
了也没用,恶心阿
祝你能拿到offer :)

【在 h**********d 的大作中提到】
: 我觉得题目本身不算难,我看版上的难题都没问道。。。
: 但是他们就题目本身引申的东西我都没准备过,比如算sqrt float的精确度和时间复杂
: 度关系,还有paint fill的method stack,也可能是大家发面经的时候没提到这部分,
: 我从没仔细想过,其实也是自己平时太粗心了

h**********d
发帖数: 4313
12
是阿,所以回来越想越难过
谢谢你的祝福:)

【在 g*****e 的大作中提到】
: 我觉得跟其他人发的amazon的coding题比起来,你的更麻烦些,当然我比较菜了...
: 相比g和f,当然这些题还是比较常见或者可以马上有idea的.
: ps,据我所知bar raiser不光是challenge candidate,如果丫不让人过的话其他人都过
: 了也没用,恶心阿
: 祝你能拿到offer :)

h**********d
发帖数: 4313
13
我是用binary search弄的。。。。回头仔细研究一下你这个解法

【在 g**e 的大作中提到】
: 重新再学习一下
: float Q_rsqrt( float number )
: {
: long i;
: float x2, y;
: const float threehalfs = 1.5F;
: x2 = number * 0.5F;
: y = number;
: i = * ( long * ) &y; // evil floating point bit level hacking
: i = 0x5f3759df - ( i >> 1 ); // what the fuck?

h**********d
发帖数: 4313
14
一个bitmap/matrix,往里填色,见career cup

【在 g*********s 的大作中提到】
: what is paint fill and what is method stack?
g**e
发帖数: 6127
15
用newton's method,收敛快很多

【在 h**********d 的大作中提到】
: 我是用binary search弄的。。。。回头仔细研究一下你这个解法
r*******e
发帖数: 7583
16
这个bt的解法依赖于0x5f3759df这个神奇的初值
不是一般的思路能够想到的。。

【在 h**********d 的大作中提到】
: 我是用binary search弄的。。。。回头仔细研究一下你这个解法
n********p
发帖数: 708
17
bless~~~~~~~~~~~~
i***e
发帖数: 452
18
big bless.
楼主能不能展开说说重建二叉树的那题呢? <PARENT, CHILD>是数值还是指针呢?
不是很明白题目的意思拉 能不能举个例子啊 谢谢
H**d
发帖数: 152
19
bless mm.
祝拿OFFER~
h**********d
发帖数: 4313
20
比如输入是{(A,B),(A,C),(B,D),(B,F),(H,A),....}
树应该是这样的, 最后返回root
H
/
A
/ \
B C
/ \
D F



【在 i***e 的大作中提到】
: big bless.
: 楼主能不能展开说说重建二叉树的那题呢? <PARENT, CHILD>是数值还是指针呢?
: 不是很明白题目的意思拉 能不能举个例子啊 谢谢

相关主题
感觉Binary Tree Postorder Traversal的iterative是三种traversal中最难的FB 面经
G的一道考题yahoo onsite
谁能给个Serialization/Deserialization of a Binary Tree Java版完整code?a d d e p a r面经, 目测已挂
进入JobHunting版参与讨论
g*********s
发帖数: 1782
21
what is the complexity requirement?
i think O(NlgN) is easy to come up with.

【在 h**********d 的大作中提到】
: 比如输入是{(A,B),(A,C),(B,D),(B,F),(H,A),....}
: 树应该是这样的, 最后返回root
: H
: /
: A
: / \
: B C
: / \
: D F
:

g*********s
发帖数: 1782
22
oh, actually if we do hash map, O(N) is enough.

【在 g*********s 的大作中提到】
: what is the complexity requirement?
: i think O(NlgN) is easy to come up with.

i***e
发帖数: 452
23

how to code it in O(n) ? assume you have hash map ?

【在 g*********s 的大作中提到】
: oh, actually if we do hash map, O(N) is enough.
h**********d
发帖数: 4313
24
对,时间空间都是O(n)

【在 g*********s 的大作中提到】
: oh, actually if we do hash map, O(N) is enough.
h**********d
发帖数: 4313
25
今天和老板说了面试的经历,他说我毕业后如果想留下可以stay as long as I want..
. 还可以给我弄H1B,感动了。。
c********8
发帖数: 586
26
good luck
i***e
发帖数: 452
27
我能想的方法是先找到根节点, 然后用类似于先根的递归去做了。 还有找到ROOT的节
电应该扫描两遍吗? 有没有什么更好的方法? 楼主如何解的?

..

【在 h**********d 的大作中提到】
: 今天和老板说了面试的经历,他说我毕业后如果想留下可以stay as long as I want..
: . 还可以给我弄H1B,感动了。。

h**********d
发帖数: 4313
28
我是先遍历的同时,用一个hashset记录已经创建的TreeNode,用于deserialize;另一
个hashmap记录parent,child信息,key存child,value存parent。
最后比较hashset和hashMap的keyset,hashmap应该少一个节点,就是root节点,原因
是二叉数root没有parent

【在 i***e 的大作中提到】
: 我能想的方法是先找到根节点, 然后用类似于先根的递归去做了。 还有找到ROOT的节
: 电应该扫描两遍吗? 有没有什么更好的方法? 楼主如何解的?
:
: ..

m*****k
发帖数: 731
29
for joseph's problem, just googled this page: http://acm.uva.es/archive/nuevoportal/data/problem.php?p=3521
There are n persons numbered from 0 to n - 1 standing in a circle. The
person number k, counting from the person number 0, is executed. After that
the person number k of the remaining persons is executed, counting from the
person after the last executed one. The process continues until only one
person is left. This person is a survivor. The problem is, given n and k
detect the survivor's number in the original circle.
Of course, all of you know the way to solve this problem. The solution is
very short, all you need is one cycle:
r := 0;
for i from 1 to n do
r := (r + k) mod i;
return r;
I do not understand this solution at all, and I tested n=5 and k=1, it runs
and returns 4, but I manually get the right answer should be 2 as follows:
init:
0 1 2 3 4
0 2 3 4 1 is killed, counting from 2
0 2 4 3 is killed, counting from 4
2 4 0 is killed counting from 2,
2 4 killed
Did I miss something?
m****i
发帖数: 650
30
我是先遍历的同时,用一个hashset记录已经创建的TreeNode,用于deserialize;另一
个hashmap记录parent,child信息,key存child,value存parent。
最后比较hashset和hashMap的keyset,hashmap应该少一个节点,就是root节点,原因
是二叉数root没有parent

=========================
这个hashset应该是hashmp吧, key是A,B or H..., value是建立的TreeNode. 不然怎
么trace相应的值已经建了TreeNode? i.e (A, TreeNode(A))pair. 如果用hashset,
是 值存放TreeNode(A)是一个pointor or reference,
以后无法Trace back!

【在 i***e 的大作中提到】
: 我能想的方法是先找到根节点, 然后用类似于先根的递归去做了。 还有找到ROOT的节
: 电应该扫描两遍吗? 有没有什么更好的方法? 楼主如何解的?
:
: ..

相关主题
分享一个图钉面筋问phone address book design
Second round phone interview with eBayhash_map 的遍历问题
Java 面试关于map 和set请教一个新鲜算法面试题
进入JobHunting版参与讨论
m****i
发帖数: 650
31
我是先遍历的同时,用一个hashset记录已经创建的TreeNode,用于deserialize;另一
个hashmap记录parent,child信息,key存child,value存parent。
最后比较hashset和hashMap的keyset,hashmap应该少一个节点,就是root节点,原因
是二叉数root没有parent

=========================
这个hashset应该是hashmp吧, key是A,B or H..., value是建立的TreeNode. 不然怎
么trace相应的值已经建了TreeNode? i.e (A, TreeNode(A))pair. 如果用hashset,
是 值存放TreeNode(A)是一个pointor or reference,
以后无法Trace back!

【在 i***e 的大作中提到】
: 我能想的方法是先找到根节点, 然后用类似于先根的递归去做了。 还有找到ROOT的节
: 电应该扫描两遍吗? 有没有什么更好的方法? 楼主如何解的?
:
: ..

m****i
发帖数: 650
32
我是先遍历的同时,用一个hashset记录已经创建的TreeNode,用于deserialize;另一
个hashmap记录parent,child信息,key存child,value存parent。
最后比较hashset和hashMap的keyset,hashmap应该少一个节点,就是root节点,原因
是二叉数root没有parent

=========================
这个hashset应该是hashmp吧, key是A,B or H..., value是建立的TreeNode. 不然怎
么trace相应的值已经建了TreeNode? i.e (A, TreeNode(A))pair. 如果用hashset,
是 值存放TreeNode(A)是一个pointor or reference,
以后无法Trace back!

【在 i***e 的大作中提到】
: 我能想的方法是先找到根节点, 然后用类似于先根的递归去做了。 还有找到ROOT的节
: 电应该扫描两遍吗? 有没有什么更好的方法? 楼主如何解的?
:
: ..

m****i
发帖数: 650
33
我是先遍历的同时,用一个hashset记录已经创建的TreeNode,用于deserialize;另一
个hashmap记录parent,child信息,key存child,value存parent。
最后比较hashset和hashMap的keyset,hashmap应该少一个节点,就是root节点,原因
是二叉数root没有parent

=========================
这个hashset应该是hashmp吧, key是A,B or H..., value是建立的TreeNode. 不然怎
么trace相应的值已经建了TreeNode? i.e (A, TreeNode(A))pair. 如果用hashset,
是 值存放TreeNode(A)是一个pointor or reference,
以后无法Trace back!

【在 i***e 的大作中提到】
: 我能想的方法是先找到根节点, 然后用类似于先根的递归去做了。 还有找到ROOT的节
: 电应该扫描两遍吗? 有没有什么更好的方法? 楼主如何解的?
:
: ..

m****i
发帖数: 650
34

for joseph's problem, just googled this page:
http://acm.uva.es/archive/nuevoportal/data/problem.php?p=3521
There are n persons numbered from 0 to n - 1 standing in a circle. The
person number k, counting from the person number 0, is executed. After that
the person number k of the remaining persons is executed, counting from the
person after the last executed one. The process continues until only one
person is left. This person is a survivor. The problem is, given n and k
detect the survivor's number in the original circle.
Of course, all of you know the way to solve this problem. The solution is
very short, all you need is one cycle:
r := 0;
for i from 1 to n do
r := (r + k) mod i;
return r;
I do not understand this solution at all, and I tested n=5 and k=1, it runs
and returns 4, but I manually get the right answer should be 2 as follows:
init:
0 1 2 3 4
0 2 3 4 1 is killed, counting from 2
0 2 4 3 is killed, counting from 4
2 4 0 is killed counting from 2,
2 4 killed
Did I miss something?
For 0 based i.e k = 0, 1, 2... inti: 0 1 2 3 4
r := 0;
for i from 1 to n do
r := (r + k + 1) mod i;
return r;
For 1 based i.e k = 1, 2... inti: 1 2 3 4 5
r := 0;
for i from 1 to n do
r := (r + k) mod i;
return r + 1;

【在 m*****k 的大作中提到】
: for joseph's problem, just googled this page: http://acm.uva.es/archive/nuevoportal/data/problem.php?p=3521
: There are n persons numbered from 0 to n - 1 standing in a circle. The
: person number k, counting from the person number 0, is executed. After that
: the person number k of the remaining persons is executed, counting from the
: person after the last executed one. The process continues until only one
: person is left. This person is a survivor. The problem is, given n and k
: detect the survivor's number in the original circle.
: Of course, all of you know the way to solve this problem. The solution is
: very short, all you need is one cycle:
: r := 0;

l****6
发帖数: 1180
35
bless !
m*****k
发帖数: 731
36
thanks, I figured the k base out afterwards, but still no idea when this
loop works and how to prove it is correct.
1 (共1页)
进入JobHunting版参与讨论
相关主题
yahoo onsite最近变硬那家的面经
a d d e p a r面经, 目测已挂今天面试惨败,分享面经
分享一个图钉面筋讨论Amazon的一道题:根节点到叶节点之间最小和,并打印路径
Second round phone interview with eBayc语言实现TreeFee
Java 面试关于map 和setG家实习电面总结
问phone address book designleetcode 上单链表转BST那道题求指导
hash_map 的遍历问题狗狗家onsite面经
请教一个新鲜算法面试题感觉Binary Tree Postorder Traversal的iterative是三种traversal中最难的
相关话题的讨论汇总
话题: treenode话题: hashset话题: counting话题: person话题: hashmap