找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

楼主: PattyZhou
收起左侧

[Google] 狗狗新鲜实习面经

[复制链接]

1183

主题

187

精华

3729

积分

神级会员

Rank: 7Rank: 7Rank: 7

积分
3729
发表于 2-6-2017 09:49 PM | 显示全部楼层

@NoOne: sure, it could be incomming requests on a server, but still, a heap is not necessary, since requests will arrive in sequential order. So, they are already ordered in the sense that the oldest is next on a FIFO, there is no need to change the order. One can just consume in the order they arrived and only process them if they are younger than a second. Seems a bit simple, well, I maybe just didn't get the question at all...

1153

主题

172

精华

3562

积分

神级会员

Rank: 7Rank: 7Rank: 7

积分
3562
发表于 2-6-2017 09:49 PM | 显示全部楼层

I don't understand why you even need a data structure for this at all:

Your req handler could simply look at the req time at the moment it responds and if the current time - req time > 1000ms just call req.write(429). req.close(). To me, that seems far simpler and faster than building a data structure to handle this.

0

主题

0

精华

1

积分

新米人

Rank: 1

积分
1
发表于 2-8-2017 03:29 PM 来自美国米群网手机版 | 显示全部楼层
8cdvs回帖支持!~~~
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表