class RecentCounter(object):
def __init__(self):
self.queue = []
def ping(self, t):
"""
:type t: int
:rtype: int
"""
self.queue.append(t)
while self.queue and self.queue[0] < t - 3000:
self.queue.pop(0)
return len(self.queue)
# Your RecentCounter object will be instantiated and called as such:
# obj = RecentCounter()
# param_1 = obj.ping(t)
Download Number of Recent Calls.pyLeetcode 933 Number of Recent Calls problem solution in python3 with explanation. This is the best place to expand your knowledge and get prepared for your next interview.
Feedback is the most important part of any website.
If you have any query, suggestion or feedback, Please feel free to contact us.