933. 最近的请求次数
小于 1 分钟
933. 最近的请求次数简单
class RecentCounter {
List<Integer> record = new ArrayList<>();
public RecentCounter() {
}
public int ping(int t) {
int res = 0;
record.add(t);
for (int i = record.size() - 1; i >= 0; i--) {
if(record.get(i) <= t && record.get(i) >= t - 3000) res++;
else return res;
}
return res;
}
}
Powered by Waline v2.15.5