由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - amazon on-site interview
相关主题
判断一个树是不是另一个树的子树?想到一道老题
MS面试题麻烦谁贴一个bug free的BST next node
请教一个BST找Median的题目Lowest Common Ancestor of multiple nodes in a binary tree
微软面试的一道题How to find the kth biggest number in a BST
这种解法对吗?merge two BSTBST 找重复节点数
一道二叉树的老题问道题
一道G家题目的思路Lowest common ancestor of two nodes of Binary Tree
树 inorder下个节点最好办法是啥一道非常伪善的面试题
相关话题的讨论汇总
话题: node话题: confidence话题: software话题: interview话题: amazon
进入JobHunting版参与讨论
1 (共1页)
c*********n
发帖数: 96
1
It is yesterday.
I caught very bad cold for about a week and it's close to the worst when I
interviewed with amazon. But I still went as arranged. For I have confidence
in my Lord.
I met 6 people. The first one is an HR staff. The rest 5 are engineers and
product managers. A product manager had lunch with me, which was also part
of the interview.
Omitting the first person's questions. (why amazon? Why physics --> software
?)
The second person asked me 2 easy questions: reverse string and find al
f*********5
发帖数: 576
2
congratulations
could u say something about your phone interview?
thanks

confidence
software
the

【在 c*********n 的大作中提到】
: It is yesterday.
: I caught very bad cold for about a week and it's close to the worst when I
: interviewed with amazon. But I still went as arranged. For I have confidence
: in my Lord.
: I met 6 people. The first one is an HR staff. The rest 5 are engineers and
: product managers. A product manager had lunch with me, which was also part
: of the interview.
: Omitting the first person's questions. (why amazon? Why physics --> software
: ?)
: The second person asked me 2 easy questions: reverse string and find al

f*********5
发帖数: 576
3
could u share your result for below?
But finally, I came back to the classical tree-algorithm. I
almost got the correct answer -- with a little piece missing.

when I
confidence
and
part
software
all the

【在 c*********n 的大作中提到】
: It is yesterday.
: I caught very bad cold for about a week and it's close to the worst when I
: interviewed with amazon. But I still went as arranged. For I have confidence
: in my Lord.
: I met 6 people. The first one is an HR staff. The rest 5 are engineers and
: product managers. A product manager had lunch with me, which was also part
: of the interview.
: Omitting the first person's questions. (why amazon? Why physics --> software
: ?)
: The second person asked me 2 easy questions: reverse string and find al

g*******y
发帖数: 1930
4
恭喜物理转CS的同志!
欢饮来西雅图

confidence
software
the

【在 c*********n 的大作中提到】
: It is yesterday.
: I caught very bad cold for about a week and it's close to the worst when I
: interviewed with amazon. But I still went as arranged. For I have confidence
: in my Lord.
: I met 6 people. The first one is an HR staff. The rest 5 are engineers and
: product managers. A product manager had lunch with me, which was also part
: of the interview.
: Omitting the first person's questions. (why amazon? Why physics --> software
: ?)
: The second person asked me 2 easy questions: reverse string and find al

s********l
发帖数: 998
5
cong~
could you tell us how you designed for this problem?
"Then his questions was "design an architecture such that it has
best availability and scalability"

confidence
software
the

【在 c*********n 的大作中提到】
: It is yesterday.
: I caught very bad cold for about a week and it's close to the worst when I
: interviewed with amazon. But I still went as arranged. For I have confidence
: in my Lord.
: I met 6 people. The first one is an HR staff. The rest 5 are engineers and
: product managers. A product manager had lunch with me, which was also part
: of the interview.
: Omitting the first person's questions. (why amazon? Why physics --> software
: ?)
: The second person asked me 2 easy questions: reverse string and find al

c*********n
发帖数: 96
6
could u share your result for below?
But finally, I came back to the classical tree-algorithm. I
almost got the correct answer -- with a little piece missing.
basically the solution is very similar to in-order traversal: you just need
to count how many nodes you have traversed so far. As soon as you got enough
, you return that node. If you finished without reaching the number, you
return null. You need to define a pair structure as the return
value, where int represents the number o
b******v
发帖数: 1493
7
cong! thanks for sharing!

confidence
software
the

【在 c*********n 的大作中提到】
: It is yesterday.
: I caught very bad cold for about a week and it's close to the worst when I
: interviewed with amazon. But I still went as arranged. For I have confidence
: in my Lord.
: I met 6 people. The first one is an HR staff. The rest 5 are engineers and
: product managers. A product manager had lunch with me, which was also part
: of the interview.
: Omitting the first person's questions. (why amazon? Why physics --> software
: ?)
: The second person asked me 2 easy questions: reverse string and find al

j**l
发帖数: 2911
8
这个使用了pair的思想就是把原本也可以用递归函数实现的count一棵子树的节点总数,放到逆中序遍历的递归函数里头,共享同一个递归过程。这个思想同样可以用来求depth, 进而可以用来求二叉树的直径。好处都是无须再单独定义一个递归的count节点的函数和一个递归的求最大depth的函数,也无须把额外的节点个数信息或者depth信息保存到节点数据里。

need
enough
.

【在 c*********n 的大作中提到】
: could u share your result for below?
: But finally, I came back to the classical tree-algorithm. I
: almost got the correct answer -- with a little piece missing.
: basically the solution is very similar to in-order traversal: you just need
: to count how many nodes you have traversed so far. As soon as you got enough
: , you return that node. If you finished without reaching the number, you
: return null. You need to define a pair structure as the return
: value, where int represents the number o

z*******y
发帖数: 578
9
cong!! well done
x********r
发帖数: 1206
10
Cong! 发包子吧!
相关主题
一道二叉树的老题想到一道老题
一道G家题目的思路麻烦谁贴一个bug free的BST next node
树 inorder下个节点最好办法是啥Lowest Common Ancestor of multiple nodes in a binary tree
进入JobHunting版参与讨论
f*********5
发帖数: 576
11
I see
u want to use recursion to get the result.
while my solution is just use stack to do in-order traverse.
void traverse(Node* root)
{
Node *current = root;
Stack stack;
while (current!=NULL || !stack.empty)
{
if (current != NULL)
{
if (!stack.empty() && current->left == stack.top())
{counter++;
if (counter==n) { printf; return;}
current=null;
}
else { stack.push(current->left)

【在 c*********n 的大作中提到】
: could u share your result for below?
: But finally, I came back to the classical tree-algorithm. I
: almost got the correct answer -- with a little piece missing.
: basically the solution is very similar to in-order traversal: you just need
: to count how many nodes you have traversed so far. As soon as you got enough
: , you return that node. If you finished without reaching the number, you
: return null. You need to define a pair structure as the return
: value, where int represents the number o

j**l
发帖数: 2911
12
这个方法虽然直接,但却是O(n)的
This problem could be solved in O(log n) time if the BST contained the
number of nodes under a root
如果不允许把子树元素个数信息放到node中, 可以把算子树元素个数的递归算法,跟查
找kth node的递归算法合并在一起, 共享一个递归过程。复杂度是O(log n)

【在 f*********5 的大作中提到】
: I see
: u want to use recursion to get the result.
: while my solution is just use stack to do in-order traverse.
: void traverse(Node* root)
: {
: Node *current = root;
: Stack stack;
: while (current!=NULL || !stack.empty)
: {
: if (current != NULL)

s********l
发帖数: 998
13
算子树个数的算法 也是o(n)啊~
怎么就logn的?

【在 j**l 的大作中提到】
: 这个方法虽然直接,但却是O(n)的
: This problem could be solved in O(log n) time if the BST contained the
: number of nodes under a root
: 如果不允许把子树元素个数信息放到node中, 可以把算子树元素个数的递归算法,跟查
: 找kth node的递归算法合并在一起, 共享一个递归过程。复杂度是O(log n)

j**l
发帖数: 2911
14
你说的对,我已经改了。
只有直接从节点里取出子树元素个数信息的情形下,才可以是O(log n)的。相当于空间
换时间并且作了预处理。

【在 s********l 的大作中提到】
: 算子树个数的算法 也是o(n)啊~
: 怎么就logn的?

n***r
发帖数: 105
15
没看懂,啥叫“放到逆中序遍历的递归函数里头,共享同一个递归过程”?
recursive去count node number,难到不是这样写:
int count(node *root)
{
if (!root)
return 0;

return (1+ count(root->left) + count(root->right);
}
本来就无须单独定义一个递归的count节点的函数。

数,放到逆中序遍历的递归函数里头,共享同一个递归过程。这个思想同样可以用来求
depth, 进而可以用来求二叉树的直径。好处都是无须再单独定义一个递归的count节点
的函数和一个递归的求最大d

【在 j**l 的大作中提到】
: 这个使用了pair的思想就是把原本也可以用递归函数实现的count一棵子树的节点总数,放到逆中序遍历的递归函数里头,共享同一个递归过程。这个思想同样可以用来求depth, 进而可以用来求二叉树的直径。好处都是无须再单独定义一个递归的count节点的函数和一个递归的求最大depth的函数,也无须把额外的节点个数信息或者depth信息保存到节点数据里。
:
: need
: enough
: .

1 (共1页)
进入JobHunting版参与讨论
相关主题
一道非常伪善的面试题这种解法对吗?merge two BST
一道面试题一道二叉树的老题
g家面经一道G家题目的思路
面试题树 inorder下个节点最好办法是啥
判断一个树是不是另一个树的子树?想到一道老题
MS面试题麻烦谁贴一个bug free的BST next node
请教一个BST找Median的题目Lowest Common Ancestor of multiple nodes in a binary tree
微软面试的一道题How to find the kth biggest number in a BST
相关话题的讨论汇总
话题: node话题: confidence话题: software话题: interview话题: amazon