Redian新闻
>
国内Google电面两轮 已挂
avatar
国内Google电面两轮 已挂# JobHunting - 待字闺中
C*w
1
10月17日,第一轮电面:
第一题:上海的电话isTree(vector >& edges); (离散化+dfs判环
判联通)
第二题,
Given a 2D space of maximum size NxN which supports two operations :
[1] void UPDATE(x,y,v) - sets the value of cell [x,y] to v
[2] int QUERY(x1,y1,x2,y2) - returns sub-rectangle sum (x1,y1) to (x2,
y2)
inclusive, and there is an infinite stream of such 2 types of
operations which have to supported. How would you store the values for
efficient updates and retrievals ? (二维线段树 说算法+分析复杂度)
第一轮答得还可以。
10月30日,第二轮电面:(挂)
美国的电话,面试官很nice:
第一题。一个二叉树,节点值有正有负,求树中的任意路径的最大值。路径的值就
是路径经过点的值的和。然后我说dfs,面试官就让写代码 。 写代码一开始dfs的接
口声明有问题,期间停下来修改了一下,然后写完。被面试官查出1个bug。面试官提示
了,一开始找出了另外个bug;面试官又提示了一下,才找出了面试官想要我fix的bug
。杯具。
第二题。给三个字符串,a,b,c。问a 和b 能不能组成c,且保证c 中a b 的字母
顺序不变。 一开始我给了一个没验证贪心的想法。然后面试官让我验证或举个反例。
我想贪心多数没戏,就又说了种dp的思路。面试官让我写下来。我写完之后,让我解释
了解释。然后突然悲催地发现我的解法是O(2^n)的。。面试后想想如果我的解法状态去
重后,就和普通的dp无异了。。 杯具 。。 然后就挂了。
哎,悲伤,简单题目答成这样,白白浪费了这次机会。
背景:国内渣本科毕业一年,有ACM竞赛经验。平常做算法题还可以,leetcode上
刷题也从没看过其他人的题解。还是把google电面想的太easy了,所以心态上有松懈。
而且加之早上起早有些困。。。 总之这些都是次要原因,主要还是因为太他妈挫了。
好好努力,来年再战!
avatar
a*m
2
谢分享 二叉树最大路径 好像是leetcode 原题啊
avatar
j*t
3
貌似第一题不是leetcode原题。其他还好。至少第二面都是原题。
avatar
l*n
4
第三个的最大路径用dfs怎么做的?感觉是recursion的问题啊。

【在 C******w 的大作中提到】
: 10月17日,第一轮电面:
: 第一题:上海的电话isTree(vector >& edges); (离散化+dfs判环
: 判联通)
: 第二题,
: Given a 2D space of maximum size NxN which supports two operations :
: [1] void UPDATE(x,y,v) - sets the value of cell [x,y] to v
: [2] int QUERY(x1,y1,x2,y2) - returns sub-rectangle sum (x1,y1) to (x2,
: y2)
: inclusive, and there is an infinite stream of such 2 types of
: operations which have to supported. How would you store the values for

avatar
P*r
5
最大路径不是也是leetcode上的吗,一般都考虑用recursion.
请问第二题怎么解?能展开一下吗?

【在 l*n 的大作中提到】
: 第三个的最大路径用dfs怎么做的?感觉是recursion的问题啊。
avatar
f*4
6
第二面都是leetcode原题吧感觉,怎么会挂呢。。
avatar
s*n
7
国内题目感觉跟美国题目不是一个套路的
avatar
C*w
8
刚刚看了下,确实是leetcode原题。leetcode没刷全,只刷了100道。这两道题没做。
凄惨。
avatar
f*x
9
同挂,一起加油!明年再来!
avatar
n*e
10
楼主能说说第一轮店面的第二题吗?
能展开说说如何用二维线段树来做吗?

【在 C******w 的大作中提到】
: 10月17日,第一轮电面:
: 第一题:上海的电话isTree(vector >& edges); (离散化+dfs判环
: 判联通)
: 第二题,
: Given a 2D space of maximum size NxN which supports two operations :
: [1] void UPDATE(x,y,v) - sets the value of cell [x,y] to v
: [2] int QUERY(x1,y1,x2,y2) - returns sub-rectangle sum (x1,y1) to (x2,
: y2)
: inclusive, and there is an infinite stream of such 2 types of
: operations which have to supported. How would you store the values for

avatar
z*s
11
一面题一没看懂,什么叫isTree,判断是不是树?怎么还用离散化了?
二面题一直接树链剖分。
二面题二也没看懂,什么叫用a,b构成c,怎么构?
avatar
e*s
12
原题,原题,一切都是因为原题
avatar
n*t
13
no disrespect at all.
but, with this kind of effort, people should try to make much bigger money
from market, instead of trying to find an opp to work for other people.
avatar
c*p
14
mark
avatar
n*f
15
楼主ACM都忘光了吧。。。这4题都是ACM基本题啊亲
一面第一题,用并查集更好些
一面第二题,如果要写code的话,用树状数组更好写
二面第一题,别说是二叉树了,就是多叉树都应该秒了它。这丫不就是最大子段和跑到
树上去了么
二面第二题,O(n^2)DP
avatar
C*w
16
1.1 就是判断是否是树,输入的val有可能很大,但节点数很小,所以离散化
2.1 给会树链剖分的大牛跪
2.2 ab cd combine 成 acbd

【在 z****s 的大作中提到】
: 一面题一没看懂,什么叫isTree,判断是不是树?怎么还用离散化了?
: 二面题一直接树链剖分。
: 二面题二也没看懂,什么叫用a,b构成c,怎么构?

avatar
C*w
17
确实。。。
毕业一年多,没正经做过题
看来以后要多刷刷TC CF比赛了。。。

【在 n*****f 的大作中提到】
: 楼主ACM都忘光了吧。。。这4题都是ACM基本题啊亲
: 一面第一题,用并查集更好些
: 一面第二题,如果要写code的话,用树状数组更好写
: 二面第一题,别说是二叉树了,就是多叉树都应该秒了它。这丫不就是最大子段和跑到
: 树上去了么
: 二面第二题,O(n^2)DP

avatar
t*g
18
不都是leetcode原题嘛
avatar
m*t
19
How to solve this one?
Given a 2D space of maximum size NxN which supports two operations :
[1] void UPDATE(x,y,v) - sets the value of cell [x,y] to v
[2] int QUERY(x1,y1,x2,y2) - returns sub-rectangle sum (x1,y1) to (x2,
y2)
inclusive, and there is an infinite stream of such 2 types of
operations which have to supported. How would you store the values for
efficient updates and retrievals ?
avatar
w*s
20
解答:
http://hawstein.com/posts/binary-indexed-trees.html

【在 m*****t 的大作中提到】
: How to solve this one?
: Given a 2D space of maximum size NxN which supports two operations :
: [1] void UPDATE(x,y,v) - sets the value of cell [x,y] to v
: [2] int QUERY(x1,y1,x2,y2) - returns sub-rectangle sum (x1,y1) to (x2,
: y2)
: inclusive, and there is an infinite stream of such 2 types of
: operations which have to supported. How would you store the values for
: efficient updates and retrievals ?

avatar
e*n
22
有点难啊
avatar
x*r
23
问个简单问题。
第一轮电面和第二轮电面第二题分别对应于Leetcode的哪个题?
BTW,我Leetcode没做完。

【在 C******w 的大作中提到】
: 10月17日,第一轮电面:
: 第一题:上海的电话isTree(vector >& edges); (离散化+dfs判环
: 判联通)
: 第二题,
: Given a 2D space of maximum size NxN which supports two operations :
: [1] void UPDATE(x,y,v) - sets the value of cell [x,y] to v
: [2] int QUERY(x1,y1,x2,y2) - returns sub-rectangle sum (x1,y1) to (x2,
: y2)
: inclusive, and there is an infinite stream of such 2 types of
: operations which have to supported. How would you store the values for

avatar
P*k
24
这个不就是用integral image
先建一个NxN的pre-sum数组,然后这个数组的(i,j)元素存的是从(0, 0)到(i, j)的
subarray的和,
这样每次query任意sub-array的和,只用取出对应这个pre-sum数组的四个顶点的值
A -----B
| |
| |
C-----D
然后计算A+D-B-C就行了,这样query就是O(1).

【在 m*****t 的大作中提到】
: How to solve this one?
: Given a 2D space of maximum size NxN which supports two operations :
: [1] void UPDATE(x,y,v) - sets the value of cell [x,y] to v
: [2] int QUERY(x1,y1,x2,y2) - returns sub-rectangle sum (x1,y1) to (x2,
: y2)
: inclusive, and there is an infinite stream of such 2 types of
: operations which have to supported. How would you store the values for
: efficient updates and retrievals ?

avatar
c*0
25
你的方法对于query很有效。但是对update不够高效。可能要把整个matrix遍历一遍来
update。

【在 P**********k 的大作中提到】
: 这个不就是用integral image
: 先建一个NxN的pre-sum数组,然后这个数组的(i,j)元素存的是从(0, 0)到(i, j)的
: subarray的和,
: 这样每次query任意sub-array的和,只用取出对应这个pre-sum数组的四个顶点的值
: A -----B
: | |
: | |
: C-----D
: 然后计算A+D-B-C就行了,这样query就是O(1).

avatar
x*w
26
一面第二题logicly quadtree
avatar
C*w
27
10月17日,第一轮电面:
第一题:上海的电话isTree(vector >& edges); (离散化+dfs判环
判联通)
第二题,
Given a 2D space of maximum size NxN which supports two operations :
[1] void UPDATE(x,y,v) - sets the value of cell [x,y] to v
[2] int QUERY(x1,y1,x2,y2) - returns sub-rectangle sum (x1,y1) to (x2,
y2)
inclusive, and there is an infinite stream of such 2 types of
operations which have to supported. How would you store the values for
efficient updates and retrievals ? (二维线段树 说算法+分析复杂度)
第一轮答得还可以。
10月30日,第二轮电面:(挂)
美国的电话,面试官很nice:
第一题。一个二叉树,节点值有正有负,求树中的任意路径的最大值。路径的值就
是路径经过点的值的和。然后我说dfs,面试官就让写代码 。 写代码一开始dfs的接
口声明有问题,期间停下来修改了一下,然后写完。被面试官查出1个bug。面试官提示
了,一开始找出了另外个bug;面试官又提示了一下,才找出了面试官想要我fix的bug
。杯具。
第二题。给三个字符串,a,b,c。问a 和b 能不能组成c,且保证c 中a b 的字母
顺序不变。 一开始我给了一个没验证贪心的想法。然后面试官让我验证或举个反例。
我想贪心多数没戏,就又说了种dp的思路。面试官让我写下来。我写完之后,让我解释
了解释。然后突然悲催地发现我的解法是O(2^n)的。。面试后想想如果我的解法状态去
重后,就和普通的dp无异了。。 杯具 。。 然后就挂了。
哎,悲伤,简单题目答成这样,白白浪费了这次机会。
背景:国内渣本科毕业一年,有ACM竞赛经验。平常做算法题还可以,leetcode上
刷题也从没看过其他人的题解。还是把google电面想的太easy了,所以心态上有松懈。
而且加之早上起早有些困。。。 总之这些都是次要原因,主要还是因为太他妈挫了。
好好努力,来年再战!
avatar
a*m
28
谢分享 二叉树最大路径 好像是leetcode 原题啊
avatar
j*t
29
貌似第一题不是leetcode原题。其他还好。至少第二面都是原题。
avatar
l*n
30
第三个的最大路径用dfs怎么做的?感觉是recursion的问题啊。

【在 C******w 的大作中提到】
: 10月17日,第一轮电面:
: 第一题:上海的电话isTree(vector >& edges); (离散化+dfs判环
: 判联通)
: 第二题,
: Given a 2D space of maximum size NxN which supports two operations :
: [1] void UPDATE(x,y,v) - sets the value of cell [x,y] to v
: [2] int QUERY(x1,y1,x2,y2) - returns sub-rectangle sum (x1,y1) to (x2,
: y2)
: inclusive, and there is an infinite stream of such 2 types of
: operations which have to supported. How would you store the values for

avatar
P*r
31
最大路径不是也是leetcode上的吗,一般都考虑用recursion.
请问第二题怎么解?能展开一下吗?

【在 l*n 的大作中提到】
: 第三个的最大路径用dfs怎么做的?感觉是recursion的问题啊。
avatar
f*4
32
第二面都是leetcode原题吧感觉,怎么会挂呢。。
avatar
s*n
33
国内题目感觉跟美国题目不是一个套路的
avatar
C*w
34
刚刚看了下,确实是leetcode原题。leetcode没刷全,只刷了100道。这两道题没做。
凄惨。
avatar
f*x
35
同挂,一起加油!明年再来!
avatar
n*e
36
楼主能说说第一轮店面的第二题吗?
能展开说说如何用二维线段树来做吗?

【在 C******w 的大作中提到】
: 10月17日,第一轮电面:
: 第一题:上海的电话isTree(vector >& edges); (离散化+dfs判环
: 判联通)
: 第二题,
: Given a 2D space of maximum size NxN which supports two operations :
: [1] void UPDATE(x,y,v) - sets the value of cell [x,y] to v
: [2] int QUERY(x1,y1,x2,y2) - returns sub-rectangle sum (x1,y1) to (x2,
: y2)
: inclusive, and there is an infinite stream of such 2 types of
: operations which have to supported. How would you store the values for

avatar
z*s
37
一面题一没看懂,什么叫isTree,判断是不是树?怎么还用离散化了?
二面题一直接树链剖分。
二面题二也没看懂,什么叫用a,b构成c,怎么构?
avatar
e*s
38
原题,原题,一切都是因为原题
avatar
n*t
39
no disrespect at all.
but, with this kind of effort, people should try to make much bigger money
from market, instead of trying to find an opp to work for other people.
avatar
c*p
40
mark
avatar
n*f
41
楼主ACM都忘光了吧。。。这4题都是ACM基本题啊亲
一面第一题,用并查集更好些
一面第二题,如果要写code的话,用树状数组更好写
二面第一题,别说是二叉树了,就是多叉树都应该秒了它。这丫不就是最大子段和跑到
树上去了么
二面第二题,O(n^2)DP
avatar
C*w
42
1.1 就是判断是否是树,输入的val有可能很大,但节点数很小,所以离散化
2.1 给会树链剖分的大牛跪
2.2 ab cd combine 成 acbd

【在 z****s 的大作中提到】
: 一面题一没看懂,什么叫isTree,判断是不是树?怎么还用离散化了?
: 二面题一直接树链剖分。
: 二面题二也没看懂,什么叫用a,b构成c,怎么构?

avatar
C*w
43
确实。。。
毕业一年多,没正经做过题
看来以后要多刷刷TC CF比赛了。。。

【在 n*****f 的大作中提到】
: 楼主ACM都忘光了吧。。。这4题都是ACM基本题啊亲
: 一面第一题,用并查集更好些
: 一面第二题,如果要写code的话,用树状数组更好写
: 二面第一题,别说是二叉树了,就是多叉树都应该秒了它。这丫不就是最大子段和跑到
: 树上去了么
: 二面第二题,O(n^2)DP

avatar
t*g
44
不都是leetcode原题嘛
avatar
m*t
45
How to solve this one?
Given a 2D space of maximum size NxN which supports two operations :
[1] void UPDATE(x,y,v) - sets the value of cell [x,y] to v
[2] int QUERY(x1,y1,x2,y2) - returns sub-rectangle sum (x1,y1) to (x2,
y2)
inclusive, and there is an infinite stream of such 2 types of
operations which have to supported. How would you store the values for
efficient updates and retrievals ?
avatar
w*s
46
解答:
http://hawstein.com/posts/binary-indexed-trees.html

【在 m*****t 的大作中提到】
: How to solve this one?
: Given a 2D space of maximum size NxN which supports two operations :
: [1] void UPDATE(x,y,v) - sets the value of cell [x,y] to v
: [2] int QUERY(x1,y1,x2,y2) - returns sub-rectangle sum (x1,y1) to (x2,
: y2)
: inclusive, and there is an infinite stream of such 2 types of
: operations which have to supported. How would you store the values for
: efficient updates and retrievals ?

avatar
e*n
48
有点难啊
avatar
x*r
49
问个简单问题。
第一轮电面和第二轮电面第二题分别对应于Leetcode的哪个题?
BTW,我Leetcode没做完。

【在 C******w 的大作中提到】
: 10月17日,第一轮电面:
: 第一题:上海的电话isTree(vector >& edges); (离散化+dfs判环
: 判联通)
: 第二题,
: Given a 2D space of maximum size NxN which supports two operations :
: [1] void UPDATE(x,y,v) - sets the value of cell [x,y] to v
: [2] int QUERY(x1,y1,x2,y2) - returns sub-rectangle sum (x1,y1) to (x2,
: y2)
: inclusive, and there is an infinite stream of such 2 types of
: operations which have to supported. How would you store the values for

avatar
P*k
50
这个不就是用integral image
先建一个NxN的pre-sum数组,然后这个数组的(i,j)元素存的是从(0, 0)到(i, j)的
subarray的和,
这样每次query任意sub-array的和,只用取出对应这个pre-sum数组的四个顶点的值
A -----B
| |
| |
C-----D
然后计算A+D-B-C就行了,这样query就是O(1).

【在 m*****t 的大作中提到】
: How to solve this one?
: Given a 2D space of maximum size NxN which supports two operations :
: [1] void UPDATE(x,y,v) - sets the value of cell [x,y] to v
: [2] int QUERY(x1,y1,x2,y2) - returns sub-rectangle sum (x1,y1) to (x2,
: y2)
: inclusive, and there is an infinite stream of such 2 types of
: operations which have to supported. How would you store the values for
: efficient updates and retrievals ?

avatar
c*0
51
你的方法对于query很有效。但是对update不够高效。可能要把整个matrix遍历一遍来
update。

【在 P**********k 的大作中提到】
: 这个不就是用integral image
: 先建一个NxN的pre-sum数组,然后这个数组的(i,j)元素存的是从(0, 0)到(i, j)的
: subarray的和,
: 这样每次query任意sub-array的和,只用取出对应这个pre-sum数组的四个顶点的值
: A -----B
: | |
: | |
: C-----D
: 然后计算A+D-B-C就行了,这样query就是O(1).

avatar
x*w
52
一面第二题logicly quadtree
avatar
s*t
53
dp不就是穷举么。。。
avatar
f*n
54
mark
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。