public class RecentCounter
    {
        Queue<int> Q;
        public RecentCounter()
        {
            Q = new Queue<int>();
            Q.Clear();
        }

        public int Ping(int t)
        {
            Q.Enqueue(t);
            while (Q.Peek() < t - 3000)
            {
                Q.Dequeue();
            }
            return Q.Count;
        }
    }

 

posted on 2018-11-04 17:58  Sempron2800+  阅读(134)  评论(0编辑  收藏  举报