Twitter news feed

Write codeMedium35 minMeta style

Your task

Design a mini Twitter and process a list of operations: ['postTweet', userId, tweetId], ['follow', followerId, followeeId], ['unfollow', followerId, followeeId], and ['getNewsFeed', userId]. getNewsFeed returns the 10 most recent tweet ids (newest first) posted by the user or anyone they follow. A user always implicitly follows themselves; following yourself explicitly is a no-op. Return the list of feeds produced by each getNewsFeed op.

Examples

twitter_feed(ops: list[list]) -> list[list[int]]
Example 1
Inputtwitter_feed([["postTweet", 1, 5], ["getNewsFeed", 1], ["follow", 1, 2], ["postTweet", 2, 6], ["getNewsFeed", 1], ["unfollow", 1, 2], ["getNewsFeed", 1]])
Output[[5], [6, 5], [5]]