type
status
date
slug
summary
tags
category
icon
password
创建时间
Jun 11, 2025 06:25 AM
写一个
RecentCounter
类来计算特定时间范围内最近的请求。请你实现
RecentCounter
类:RecentCounter()
初始化计数器,请求数为 0 。
int ping(int t)
在时间t
添加一个新请求,其中t
表示以毫秒为单位的某个时间,并返回过去3000
毫秒内发生的所有请求数(包括新请求)。确切地说,返回在[t-3000, t]
内发生的请求数。
保证 每次对
ping
的调用都使用比之前更大的 t
值。四、队列§4.1 基础
📎 参考
- 无