w********0 发帖数: 377 | 1 本人情况,cs phd 工作了两年多了,骑驴找马。phd和工作一直在做图像处理图像识别
的项目。 从来没有做过java的项目。 leetcode也刷了两遍了。
前几天电面了linkedin。两道题:
1.insert a node in a BST. 我写了一个recursive的方法。开始漏了两句话,但是后
来没等她开口,我就自己发现加上了。
2.就是大家常说的weighted SUM nested List. 不过这个是reversed depth weight。
虽然面的时候是第一次见到,我也是用的保存每层的sum,和相对的层数,然后最后一
起加起来。
写完之后,面试官觉得也没啥问题,最后就问了问时间复杂度,空间复杂度。
最后还剩5分钟,面试官让我问问题。我就问问他们的project做啥,啥challenge之类
的。主面试官就有blabla说了一堆。然后这时候一直没开口的shadow就突然说话了,我
们还有一个最大的challenge是怎么让整个团队好好的沟通有效的工作。
当时一听这个,有点傻眼了。想着这下完了,可能对我的沟通能力不满意。
面完之后一直想,要死也死在沟通上了。或者就是他们觉得我花了7,8年作图像,c++
,然后要转到一点关系没有的java based social network很不可思议。这个当时他们
也问我为啥要面linkedin。这时我感觉不好的地方。
大家帮我分析一下,我到底死在哪里了?沟通整的这么重要吗?我该聊的也聊了。哎!
真的好难呀!怎么觉得有点工作经验但不相关的,想进flg更难似的。
另外求内推!!各种公司,如果有做computer vision的更好! | w********0 发帖数: 377 | 2 up
【在 w********0 的大作中提到】 : 本人情况,cs phd 工作了两年多了,骑驴找马。phd和工作一直在做图像处理图像识别 : 的项目。 从来没有做过java的项目。 leetcode也刷了两遍了。 : 前几天电面了linkedin。两道题: : 1.insert a node in a BST. 我写了一个recursive的方法。开始漏了两句话,但是后 : 来没等她开口,我就自己发现加上了。 : 2.就是大家常说的weighted SUM nested List. 不过这个是reversed depth weight。 : 虽然面的时候是第一次见到,我也是用的保存每层的sum,和相对的层数,然后最后一 : 起加起来。 : 写完之后,面试官觉得也没啥问题,最后就问了问时间复杂度,空间复杂度。 : 最后还剩5分钟,面试官让我问问题。我就问问他们的project做啥,啥challenge之类
| s*****r 发帖数: 43070 | | w********0 发帖数: 377 | 4 是ABC吧。看名字是Lee什么的。shadow是美国人
【在 s*****r 的大作中提到】 : 英语?面试官是老中吗,还考虑沟通能力
| l*****a 发帖数: 14598 | 5 上code吧
不看code没法说
【在 w********0 的大作中提到】 : 本人情况,cs phd 工作了两年多了,骑驴找马。phd和工作一直在做图像处理图像识别 : 的项目。 从来没有做过java的项目。 leetcode也刷了两遍了。 : 前几天电面了linkedin。两道题: : 1.insert a node in a BST. 我写了一个recursive的方法。开始漏了两句话,但是后 : 来没等她开口,我就自己发现加上了。 : 2.就是大家常说的weighted SUM nested List. 不过这个是reversed depth weight。 : 虽然面的时候是第一次见到,我也是用的保存每层的sum,和相对的层数,然后最后一 : 起加起来。 : 写完之后,面试官觉得也没啥问题,最后就问了问时间复杂度,空间复杂度。 : 最后还剩5分钟,面试官让我问问题。我就问问他们的project做啥,啥challenge之类
| w********0 发帖数: 377 | 6 这时当时的code,我copy下来了。请大牛指点。
Given a nested list of positive integers: {{1,1},2,{1,1}}
Compute the reverse depth sum of a nested list meaning the reverse depth of
each node (ie, 1 for leafs, 2 for parents of leafs, 3 for parents of parents
of leafs, etc.) times the value of that node. so the RDS of {{1,1},2,{1,1}
} would be 8 = 1*1 + 1*1 + 2*2 + 1*1 + 1*1.
{1,{4,{6}}}
6*1 + 4*2 + 1*3 = 6+8+3 = 17
struct Iterm
{
int v;
bool isInteger();
int getInteger();
list getList();
list list
}
int weightedSum(Iterm item)
{
vector levelSum;
weightedSumSub(item, 0, level_sum );
int maximalDepth=level_sum.size();
int sumRes=0;
for(i=0; i
{
sumRes+= (maximalDepth--)*(level_sum[i]);
}
return sumRes;
}
int weightedSumSub(Iterm &it, int depth, vector &level_sum )
{
int sum =0;
if(it.isIntergere)
{
if(level_sum.size()-1
level_sum.push_back(it.getInteger);
else
level_sum[depth]+=it.getInteger;
}
else
{
list- tmp = it.getList();
for(auto iter=tmp.begin(); iter!=tmp.end(); iter++ )
{
weightedSum(*iter, depth+1, levelsum );
}
}
}
list
Write an insert function for a binary search tree storing integers. You can
make any reasonable assumptions that you like about the implementation of
the binary search tree.
struct TreeNode
{
TreeNode * left;
TreeNode *right;
int val;
TreeNode(int v)
{
val=v;
left=NULL;
right =NULL;
}
}
void insert(TreeNode *root, int val)
{
if(!root)
{
TreeNode * newNode = new TreeNode(Val);
return newNode;
}
if(root->val>val)
{
if(!root->left)
root->left=new TreeNode(val);
else
insert(root->left, val);
}
else if(root->val < val)
{
if(!root->right)
root->right = new TreeNode (val);
else
insert(root-> right, val);
}
return;
}
【在 l*****a 的大作中提到】 : 上code吧 : 不看code没法说
| s*****r 发帖数: 43070 | 7 看着很不错,可能嫌你的英文不够好
of
parents
1}
【在 w********0 的大作中提到】 : 这时当时的code,我copy下来了。请大牛指点。 : Given a nested list of positive integers: {{1,1},2,{1,1}} : Compute the reverse depth sum of a nested list meaning the reverse depth of : each node (ie, 1 for leafs, 2 for parents of leafs, 3 for parents of parents : of leafs, etc.) times the value of that node. so the RDS of {{1,1},2,{1,1} : } would be 8 = 1*1 + 1*1 + 2*2 + 1*1 + 1*1. : {1,{4,{6}}} : 6*1 + 4*2 + 1*3 = 6+8+3 = 17 : struct Iterm : {
| l*****a 发帖数: 14598 | 8 你这个insert不能不用递归吗
反正从root一直往下走
另外有相等的是怎么要求的
还有你明明定义return void
why return newNode呢
of
parents
1}
【在 w********0 的大作中提到】 : 这时当时的code,我copy下来了。请大牛指点。 : Given a nested list of positive integers: {{1,1},2,{1,1}} : Compute the reverse depth sum of a nested list meaning the reverse depth of : each node (ie, 1 for leafs, 2 for parents of leafs, 3 for parents of parents : of leafs, etc.) times the value of that node. so the RDS of {{1,1},2,{1,1} : } would be 8 = 1*1 + 1*1 + 2*2 + 1*1 + 1*1. : {1,{4,{6}}} : 6*1 + 4*2 + 1*3 = 6+8+3 = 17 : struct Iterm : {
| w********0 发帖数: 377 | 9 他当时说不用考虑相等的情况。那个return可能我写的时候太紧张,写错了。他当时说
的,不要管syntax error,因为这个在IDE里很容易检测出来。莫非是因为这个code的
没写好? 他也没说不要用递归。当时写完之后,他说,第一道题,就是一个小题,很
简单。没啥。 然后就给我第二题了。
【在 l*****a 的大作中提到】 : 你这个insert不能不用递归吗 : 反正从root一直往下走 : 另外有相等的是怎么要求的 : 还有你明明定义return void : why return newNode呢 : : of : parents : 1}
| w********0 发帖数: 377 | 10 还有个问题不明白,code里有低级错误 要是面试官看出来了,不应该只出来吗?即使
当时没指出来,不也应该在题目最后写完了给指出来吗?莫非shadow看出来了 主面试
官没看出来,下来一合计,不行,这个人竟然犯这么简单的错误!确实第一题答的时候
很紧张,但是第二题的时候就渐渐适应了。
【在 l*****a 的大作中提到】 : 你这个insert不能不用递归吗 : 反正从root一直往下走 : 另外有相等的是怎么要求的 : 还有你明明定义return void : why return newNode呢 : : of : parents : 1}
| | | w********0 发帖数: 377 | 11 确实自己实力不行!
【在 w********0 的大作中提到】 : 还有个问题不明白,code里有低级错误 要是面试官看出来了,不应该只出来吗?即使 : 当时没指出来,不也应该在题目最后写完了给指出来吗?莫非shadow看出来了 主面试 : 官没看出来,下来一合计,不行,这个人竟然犯这么简单的错误!确实第一题答的时候 : 很紧张,但是第二题的时候就渐渐适应了。
| z***b 发帖数: 127 | 12 {{2},1,{4,{6}}}
楼主,这个输入应该返回多少呢? | w********0 发帖数: 377 | 13 不应该是 1*6+2*4+2*2+3*1吗?
【在 z***b 的大作中提到】 : {{2},1,{4,{6}}} : 楼主,这个输入应该返回多少呢?
| r*******e 发帖数: 971 | 14 楼主你能讲讲你那个weighted sum啥么思路么?我怀疑你挂在这道题上了。 | w********0 发帖数: 377 | 15 因为他要one pass。
我就跟他说我要用一个vector保存每层的sum值。比如{1,{2,3}4{{6}}}。
recursion之后 vector 里是 [ 1+4, 2+3, 6] 然后 用 vector里 第一个数 5* 3 +5*2
+6*1= 31。
相当于用了O(maximal depth)的空间。讨论的时候他说好 那你就xieba。 | w****a 发帖数: 710 | 16 用树结构做了一下nested sum
struct Node {
Node(int val = 0) : value(val){}
~Node() {
for(auto c : children) delete c;
children.clear();
}
void reverse_depth(int total_depth) {
if(depth > 0) depth = total_depth - depth + 1;
for(auto c : children) {
c->reverse_depth(total_depth);
}
}
int height() {
if(children.empty()) return 0;
int ret = 0;
for(auto c : children) ret = max(ret, c->height());
return ret + 1;
}
int sum() {
int sum = children.empty() ? depth * value : 0;
for(auto c : children) sum += c->sum();
return sum;
}
int reversed_sum() {
reverse_depth(height());
return sum();
}
Node* add_child(int num = 0) {
auto node = new Node(num);
children.push_back(node);
node->depth = depth+1;
return node;
}
int depth{ 0 };
int value{ 0 };
vector children;
};
void test() {
// {{1,1},2,{1,1}}
auto root = new Node();
auto son1 = root->add_child();
son1->add_child(1);
son1->add_child(1);
root->add_child(2);
auto son2 = root->add_child();
son2->add_child(1);
son2->add_child(1);
root->reverse_depth(root->height());
cout << root->sum() << endl;
delete root;
} |
|