LeetCode 933.最近的请求次数
生活随笔
收集整理的這篇文章主要介紹了
LeetCode 933.最近的请求次数
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
原題鏈接
解題思路:主要保留PING中比3000大的
class RecentCounter { public:RecentCounter() {}int ping(int t) {time.push(t);while(time.front()<t-3000){ //查詢T是否比3000大time.pop(); //T比3000小就出隊(duì)}return time.size();}queue<int> time; };/*** Your RecentCounter object will be instantiated and called as such:* RecentCounter* obj = new RecentCounter();* int param_1 = obj->ping(t);*/?
總結(jié)
以上是生活随笔為你收集整理的LeetCode 933.最近的请求次数的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: LeetCode 1021 删除最外层的
- 下一篇: Linux服务启动命令(linux 服务