Design Twitter

Design a simplified version of Twitter where users can post tweets, follow/unfollow another user, and is able to see the 10 most recent tweets in the user’s news feed. Implement the Twitter class: Twitter() Initializes your twitter object. void postTweet(int userId, int tweetId) Composes a new tweet with ID tweetId by the user userId. Each call to this function will be made with a unique tweetId. List<Integer> getNewsFeed(int userId) Retrieves...

周六 · 2024-12-14 · 4 分钟 · Yuechen

Design a Dating System

Design a simple dating system like Tinder with the following features: Register a user with their gender, age, preferences, and interests. Find matching users according to their preferred gender, preferred age range, and common interests. Implement the Tinder class: Tinder() Initializes the object. void signup(int userId, int gender, int preferredGender, int age, int minPreferredAge, int maxPreferredAge, List<String> interests) Registers a user with the given attributes. List<Integer> getMatches(int userId) Returns the...

周六 · 2024-12-07 · 3 分钟 · Yuechen

Design Facebook

Design a system like Facebook with the following features: A user can write a post. Two users can become friends with each other. Users can see all the posts written by their friends. Implement the Facebook class: Facebook() Initializes the object. void writePost(int userId, String postContent) The user with id userId writes a post with the content postContent. void addFriend(int user1, int user2) user1 and user2 become friends with each...

周六 · 2024-11-30 · 2 分钟 · Yuechen

Design Whatsapp

Design a system like Whatsapp with the following features: Send a message to a user. Create a group with some initial users. Add more users to a group. Send a message to a group. Get messages for a user. Implement the WhatsApp class: WhatsApp() Initializes the object. void sendMessage(int toUser, String message) Sends a personal message with the text message to the user with id: toUser. int createGroup(int[] initialUsers) Creates a new group that initially contains users whose ids are in the list initialUsers, and the group id is returned....

周日 · 2024-11-24 · 5 分钟 · Yuechen