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