Design a simplified version of a social media service like Twitter where users can post tweets, follow or unfollow other users, and view the
Implement the Twitter class:
Twitter() Initializes the Twitter object.
void postTweet(int userId, int tweetId) Composes a new tweet with ID tweetId published by the user userId. Each call to this function is made with a unique tweetId.
List[int] getNewsFeed(int userId) Retrieves the
void follow(int followerId, int followeeId) The user with ID followerId starts following the user with ID followeeId.
void unfollow(int followerId, int followeeId) The user with ID followerId unfollows the user with ID followeeId.
Constraints:
userId, followerId, followeeId
tweetId
All the tweets have unique IDs.
At most postTweet, getNewsFeed, follow, and unfollow.
A user cannot follow himself.
Design a simplified version of a social media service like Twitter where users can post tweets, follow or unfollow other users, and view the
Implement the Twitter class:
Twitter() Initializes the Twitter object.
void postTweet(int userId, int tweetId) Composes a new tweet with ID tweetId published by the user userId. Each call to this function is made with a unique tweetId.
List[int] getNewsFeed(int userId) Retrieves the
void follow(int followerId, int followeeId) The user with ID followerId starts following the user with ID followeeId.
void unfollow(int followerId, int followeeId) The user with ID followerId unfollows the user with ID followeeId.
Constraints:
userId, followerId, followeeId
tweetId
All the tweets have unique IDs.
At most postTweet, getNewsFeed, follow, and unfollow.
A user cannot follow himself.