Skip to content

Latest commit

 

History

History
24 lines (19 loc) · 512 Bytes

933.md

File metadata and controls

24 lines (19 loc) · 512 Bytes

933. Number of Recent Calls

Solution 1

class RecentCounter(object):

    def __init__(self):
        self.q = collections.deque([])

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

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