# 1348\. Tweet Counts Per Frequency
```python=
class TweetCounts:
def __init__(self):
self.d = defaultdict(list)
self.N = {'minute': 60, 'hour': 3600, 'day': 86400}
def recordTweet(self, tweetName: str, time: int) -> None:
insort(self.d[tweetName], int(time))
def getTweetCountsPerFrequency(self, freq: str, tweetName: str, startTime: int, endTime: int) -> List[int]:
li = self.d[tweetName]
N = self.N[freq]
time_frames = []
while startTime + N <= endTime:
time_frames.append([startTime, startTime + N - 1])
startTime += N
time_frames.append([startTime, endTime])
result = []
for start, end in time_frames:
left = bisect_left(li, start) # the leftmost >= start
right = bisect_right(li, end) - 1 # the rightmost <= end
# print(start, end, left, right, li)
count = right - left + 1 # inclusive both endpoints
result.append(count)
# print(time_frames)
return result
# Your TweetCounts object will be instantiated and called as such:
# obj = TweetCounts()
# obj.recordTweet(tweetName,time)
# param_2 = obj.getTweetCountsPerFrequency(freq,tweetName,startTime,endTime)
```