filmov
tv
Leetcode Question 355 'Design Twitter' in Java

Показать описание
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 the 10 most recent tweet IDs in the user's news feed. Each item in the news feed must be posted by users who the user followed or by the user themself. Tweets must be ordered from most recent to least recent.
void follow(int followerId, int followeeId) The user with ID followerId started following the user with ID followeeId.
void unfollow(int followerId, int followeeId) The user with ID followerId started unfollowing the user with ID followeeId.
Example 1:
Input
["Twitter", "postTweet", "getNewsFeed", "follow", "postTweet", "getNewsFeed", "unfollow", "getNewsFeed"]
[[], [1, 5], [1], [1, 2], [2, 6], [1], [1, 2], [1]]
Output
[null, null, [5], null, null, [6, 5], null, [5]]
Explanation
Twitter twitter = new Twitter();
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 the 10 most recent tweet IDs in the user's news feed. Each item in the news feed must be posted by users who the user followed or by the user themself. Tweets must be ordered from most recent to least recent.
void follow(int followerId, int followeeId) The user with ID followerId started following the user with ID followeeId.
void unfollow(int followerId, int followeeId) The user with ID followerId started unfollowing the user with ID followeeId.
Example 1:
Input
["Twitter", "postTweet", "getNewsFeed", "follow", "postTweet", "getNewsFeed", "unfollow", "getNewsFeed"]
[[], [1, 5], [1], [1, 2], [2, 6], [1], [1, 2], [1]]
Output
[null, null, [5], null, null, [6, 5], null, [5]]
Explanation
Twitter twitter = new Twitter();
Design Twitter - Leetcode 355 - Python
Leetcode Question 355 'Design Twitter' in Java
LeetCode | 355. Design Twitter | HashMap | Vector
355. Design Twitter | LEETCODE MEDIUM | HASH TABLE | DESIGN | DATA STRUCTURES
Design Twitter - LeetCode #355 - C++
Design Twitter - System design | leetcode
LEETCODE 355 - Design Twitter
LeetCode 355 | Design Twitter | OOP | HashMap | Java
No Sound Leetcode 355: Design Twitter
Design Twitter Neetcode150 Series (69 of 150) Leetcode - Second Run
Design Twitter - System Design Interview Question
LeetCode Design Problems (Part 2) | Design Twitter
L-8 leetcode 355. Design Twitter | heaps | leetcode daily challenge | Java DSA | Hindi
Design Twitter LeetCode
Design Twitter - System Design Interview
Pass Leetcode #355 Design Twitter
How many LeetCode problems should you solve? #leetcode #techinterview #developer #softwareengineer
Design Twitter - Neetcode150 Series: (70 of 150) Leetcode
Can you Design Twitter better than Elon? #shorts #twitter #layoffs #leetcode
355. Design Twitter [01/6/21 - 1/5]
355 Design Twitter I Heap & Priority Queue I Leetcode I Python I Journey
355 Design Twitter
Design Twitter - Design a Data Structure | The Code Mate
Do LeetCode THE RIGHT WAY
Комментарии