355_DesignTwitter.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:leetcode 作者: Dimen61 项目源码 文件源码
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)]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号