Design Twitter
1. The Question and Use Cases
class Twitter {
/** user post a tweet */
public void postTweet(int userId, int tweetId) {}
/** return the list of IDs of recent tweets,
from the users that the current user follows (including him/herself),
maximum 10 tweets with updated time sorted in descending order */
public List<Integer> getNewsFeed(int userId) {}
/** follower will follow the followee,
create the ID if it doesn't exist */
public void follow(int followerId, int followeeId) {}
/** follower unfollows the followee,
do nothing if the ID does not exist */
public void unfollow(int followerId, int followeeId) {}
}2. OO Design


3. Design of The Algorithm

4. Summary

Last updated