avatar
j*h
2
攒人品。
实现一个控制调用某第三方API次数的控制器。对于接收到的调用请求,一秒钟内只能
响应N次, 超过N次,就忽略。
avatar
a*n
3
chdbits

【在 S**********g 的大作中提到】
: 高清全部节目,不是分段的那种,有吗?
: 谢谢

avatar
l*y
4
你不是在P?怎么来面U啦?
avatar
S*g
5
木有账号,郁闷

【在 a*****n 的大作中提到】
: chdbits
avatar
b*5
6
google guava rate limiter..

【在 j*h 的大作中提到】
: 攒人品。
: 实现一个控制调用某第三方API次数的控制器。对于接收到的调用请求,一秒钟内只能
: 响应N次, 超过N次,就忽略。

avatar
b*5
8
你们这些人, 面经从来是发了点问题, 从来没答案。。。

【在 j*h 的大作中提到】
: 攒人品。
: 实现一个控制调用某第三方API次数的控制器。对于接收到的调用请求,一秒钟内只能
: 响应N次, 超过N次,就忽略。

avatar
j*n
9
pptv.com

【在 S**********g 的大作中提到】
: 高清全部节目,不是分段的那种,有吗?
: 谢谢

avatar
j*h
10
实现的数据结构,可以是circular array, dequeue, priority queue
class Service{
bool handleRequest(double timestamp){
}
};

【在 j*h 的大作中提到】
: 攒人品。
: 实现一个控制调用某第三方API次数的控制器。对于接收到的调用请求,一秒钟内只能
: 响应N次, 超过N次,就忽略。

avatar
b*5
11
did u ever mention google guava rate limiter? did the interviewer say that u
can't use any existing library?

【在 j*h 的大作中提到】
: 实现的数据结构,可以是circular array, dequeue, priority queue
: class Service{
: bool handleRequest(double timestamp){
: }
: };

avatar
q*c
12
Of course you cannot use other library. 看来这是个高频题。

u

【在 b**********5 的大作中提到】
: did u ever mention google guava rate limiter? did the interviewer say that u
: can't use any existing library?

avatar
b*5
13
but this goes against the spirit of uber. in fact, this goes against the
spirit of programming! why would i want to reinvent some rate limiter when
there's a perfectly good rate limiter provided to me by the excellent
engineers from google?!

【在 q********c 的大作中提到】
: Of course you cannot use other library. 看来这是个高频题。
:
: u

avatar
k*l
14
工作的角度没错
从interview的角度,好像一般更喜欢你自己能实现/优化一个常见的功能
大概意思是如果你会做看懂别人的东西会比较容易些吧

【在 b**********5 的大作中提到】
: but this goes against the spirit of uber. in fact, this goes against the
: spirit of programming! why would i want to reinvent some rate limiter when
: there's a perfectly good rate limiter provided to me by the excellent
: engineers from google?!

avatar
b*5
15
if it's a 常见的功能, then it's probably optimized already by someone else...

【在 k**l 的大作中提到】
: 工作的角度没错
: 从interview的角度,好像一般更喜欢你自己能实现/优化一个常见的功能
: 大概意思是如果你会做看懂别人的东西会比较容易些吧

avatar
f*r
16
这题和这贴相似:http://www.mitbbs.com/article_t/JobHunting/33088133.html
具体解法可以看5楼

【在 j*h 的大作中提到】
: 攒人品。
: 实现一个控制调用某第三方API次数的控制器。对于接收到的调用请求,一秒钟内只能
: 响应N次, 超过N次,就忽略。

avatar
k*a
17
感觉上可以用一个list,
每次来一个request, 判断和list head的时间间隔,
如果在1秒以外,remove list head, 直到list head在1秒以内
然后,如果队列的长度为N, 则忽略,如果不是N,那就把请求的时间加入list, 并处
理请求
但是如果多线程就比较麻烦了,可以加synchronized,但是速度不会理想
avatar
k*a
18
感觉上可以用一个list,
每次来一个request, 判断和list head的时间间隔,
如果在1秒以外,remove list head, 直到list head在1秒以内
然后,如果队列的长度为N, 则忽略,如果不是N,那就把请求的时间加入list, 并处
理请求
但是如果多线程就比较麻烦了,可以加synchronized,但是速度不会理想
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。