# -*- coding: utf-8 -*-
# @Time    : 2019/2/25 11:46
# @Author  : xulzee
# @Email   : xulzee@163.com
# @File    : 933.number-of-recent-calls.py
# @Software: PyCharm

import collections


class RecentCounter:

    def __init__(self):
        self.queue = collections.deque()

    def ping(self, t):
        """
        :type t: int
        :rtype: int
        """
        while self.queue and self.queue[0] < t - 3000:
            self.queue.popleft()
        self.queue.append(t)
        return len(self.queue)

# Your RecentCounter object will be instantiated and called as such:
# obj = RecentCounter()
# param_1 = obj.ping(t)

if __name__ == '__main__':
    # inputs:
    # ["RecentCounter", "ping", "ping", "ping", "ping"]
    # [[], [1], [100], [3001], [3002]]
    # [null, 1, 2, 3, 3]
    obj = RecentCounter()
    print(obj.ping(1), obj.ping(100), obj.ping(3001), obj.ping(3002))

6d04bd6fdd574da8664dd0b480c3de1074b23538
<mask token>


class RecentCounter:

    def __init__(self):
        self.queue = collections.deque()
    <mask token>


<mask token>

<mask token>


class RecentCounter:

    def __init__(self):
        self.queue = collections.deque()

    def ping(self, t):
        """
        :type t: int
        :rtype: int
        """
        while self.queue and self.queue[0] < t - 3000:
            self.queue.popleft()
        self.queue.append(t)
        return len(self.queue)


<mask token>

<mask token>


class RecentCounter:

    def __init__(self):
        self.queue = collections.deque()

    def ping(self, t):
        """
        :type t: int
        :rtype: int
        """
        while self.queue and self.queue[0] < t - 3000:
            self.queue.popleft()
        self.queue.append(t)
        return len(self.queue)


if __name__ == '__main__':
    obj = RecentCounter()
    print(obj.ping(1), obj.ping(100), obj.ping(3001), obj.ping(3002))

import collections


class RecentCounter:

    def __init__(self):
        self.queue = collections.deque()

    def ping(self, t):
        """
        :type t: int
        :rtype: int
        """
        while self.queue and self.queue[0] < t - 3000:
            self.queue.popleft()
        self.queue.append(t)
        return len(self.queue)


if __name__ == '__main__':
    obj = RecentCounter()
    print(obj.ping(1), obj.ping(100), obj.ping(3001), obj.ping(3002))

# -*- coding: utf-8 -*-
# @Time    : 2019/2/25 11:46
# @Author  : xulzee
# @Email   : xulzee@163.com
# @File    : 933.number-of-recent-calls.py
# @Software: PyCharm

import collections


class RecentCounter:

    def __init__(self):
        self.queue = collections.deque()

    def ping(self, t):
        """
        :type t: int
        :rtype: int
        """
        while self.queue and self.queue[0] < t - 3000:
            self.queue.popleft()
        self.queue.append(t)
        return len(self.queue)

# Your RecentCounter object will be instantiated and called as such:
# obj = RecentCounter()
# param_1 = obj.ping(t)

if __name__ == '__main__':
    # inputs:
    # ["RecentCounter", "ping", "ping", "ping", "ping"]
    # [[], [1], [100], [3001], [3002]]
    # [null, 1, 2, 3, 3]
    obj = RecentCounter()
    print(obj.ping(1), obj.ping(100), obj.ping(3001), obj.ping(3002))
