avatar
G intern电面面经# JobHunting - 待字闺中
j*1
1
回报本版,新鲜G的电面面经,顺便求bless。
(1) Suppose each request has some data, calculate the average bandwidth in
the last 1 second, 1minute, 1 hour.
这题跟careercup那道recent average request很像。
首先,不能有错误,只想出来了use a queue as moving window, and then take
average over last 1 sec, 1 minute, 1 hour. Maintain the queue by deleting
all requests information outside the 1 hour window.
其次,允许一定的错误量。这样就可以用circular array. For example, take a
circular array to store the bandwidth in each second, sample_per_sec[3600].
Then circular filling in the array. The average in last hour is the average
of the array.
(2) Existence of an integer in a sorted array.
O(log(n)) binary search.
Existence of an integer in a linked list.
貌似只能O(n)。
Visit webpages and count specific words in each webpage in a graph.
DFS/BFS, and need to take care of cycles. 这里我用了一个list to
store visited pages to avoid double counting,不知道有没有更好的data
structure
貌似G的电面variance很大啊,这些题比什么四位解码,2-d knapsack好多了。同时抱
怨一下google doc比f的collabedit难用多了。。
code有minor bug,不过都fix了,求bless能过:)
avatar
f*2
2
bless
avatar
z*0
3
bless

.
average

【在 j******1 的大作中提到】
: 回报本版,新鲜G的电面面经,顺便求bless。
: (1) Suppose each request has some data, calculate the average bandwidth in
: the last 1 second, 1minute, 1 hour.
: 这题跟careercup那道recent average request很像。
: 首先,不能有错误,只想出来了use a queue as moving window, and then take
: average over last 1 sec, 1 minute, 1 hour. Maintain the queue by deleting
: all requests information outside the 1 hour window.
: 其次,允许一定的错误量。这样就可以用circular array. For example, take a
: circular array to store the bandwidth in each second, sample_per_sec[3600].
: Then circular filling in the array. The average in last hour is the average

avatar
h*8
4
的确variance很大。我被问了三题,都是leetcode。2sum, generate parentheses 和
parentheses matching。
话说intern面试会不会参考题目难度评分啊?
avatar
P*d
5
第一题求问为什么第一种方法是不允许有错误的,第二种是允许有错误的,没看出来这
个错误对解法影响在哪里
avatar
j*1
6
第二种方法是有误差的(这个误差取决于implementation。)假设用一个sample_per_
sec[3600] to store bandwidth in each second in the last hour.
考虑一下情况:
1. msg at 0.02 sec with 1kb data
2. msg at 3600.01 sec with 1kb data.
3. query at 3600.015 for the bandwidth in last hour.
算法一会给你2kb,算法二会给你1kb。

【在 P****d 的大作中提到】
: 第一题求问为什么第一种方法是不允许有错误的,第二种是允许有错误的,没看出来这
: 个错误对解法影响在哪里

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。