Description
Design a simplified version of Twitter where users can post tweets, follow/unfollow other users, and see the 10 most recent tweets in their news feed.
Examples
Input:
postTweet(1, 5), getNewsFeed(1)Output:
[5]Explanation:
User 1 posted tweet 5.
Input:
postTweet(1, 10), postTweet(2, 20), follow(1, 2), getNewsFeed(1)Output:
[20, 10]Explanation:
User 1 posts tweet 10, user 2 posts tweet 20, then user 1 follows user 2. User 1's news feed shows tweet 20 (from followed user 2) first since it's more recent, followed by their own tweet 10.
Input:
postTweet(3, 100), postTweet(3, 200), postTweet(3, 300), follow(4, 3), unfollow(4, 3), getNewsFeed(4)Output:
[]Explanation:
User 3 posts three tweets (100, 200, 300). User 4 follows user 3 then immediately unfollows them. Since user 4 hasn't posted any tweets and isn't following anyone, their news feed is empty.
Constraints
- •
1 ≤ userId, followerId, followeeId ≤ 500 - •
0 ≤ tweetId ≤ 10⁴