def getNewsFeed(self, userId):
"""
Retrieve the 10 most recent tweet ids in the user's news feed. Each item in the news feed must be posted by users who the user followed or by the user herself. Tweets must be ordered from most recent to least recent.
:type userId: int
:rtype: List[int]
"""
tweets = heapq.merge(*(self.tweets[user]
for user in self.followees[userId] | {userId}))
return [t for _, t in itertools.islice(tweets, 10)]
评论列表
文章目录