Own Solution
class RecentCounter:
def __init__(self):
self.counts = []
self.number = None
def ping(self, t: int) -> int:
self.number = 0
self.counts.append(t)
start_range = t - 3000
index = 0
while index < len(self.counts):
if self.counts[index] >= start_range:
return len(self.counts)
else:
self.counts.pop(0)
index = 0
# Your RecentCounter object will be instantiated and called as such:
# obj = RecentCounter()
# param_1 = obj.ping(t)