Skip to content
We areTOP 1%

Design Twitter

MediumLeetCodeDesign Data Structures
Solve on LeetCode(opens in a new tab)
Track your progress
First attempt
Re-solve after a few days
Final pass before interviews
Approach hintTry it first, then reveal

Store each user's followees in a set and every tweet with a global timestamp. To build a feed, merge the tweet lists of the user and the followees with a heap and stop after the 10 most recent.

More in Design Data Structures

Design Data Structures questions
#ProblemPlatformDifficultyOpen1st1st Visit2nd2nd VisitRevRevise
1Insert Delete GetRandom O(1)LeetCodeMedium Solve Insert Delete GetRandom O(1) on LeetCode (opens in a new tab)
2LRU CacheLeetCodeMedium Solve LRU Cache on LeetCode (opens in a new tab)
3Design TwitterLeetCodeMedium Solve Design Twitter on LeetCode (opens in a new tab)
4Snapshot ArrayLeetCodeMedium Solve Snapshot Array on LeetCode (opens in a new tab)
5Glass CarvingCodeforcesMedium 1500Solve Glass Carving on Codeforces (opens in a new tab)
6Lunar New Year and Food OrderingCodeforcesMedium 1500Solve Lunar New Year and Food Ordering on Codeforces (opens in a new tab)
7Constructing the ArrayCodeforcesMedium 1600Solve Constructing the Array on Codeforces (opens in a new tab)
8Two TeamsCodeforcesHard 1800Solve Two Teams on Codeforces (opens in a new tab)
9Maximum Frequency StackLeetCodeHard Solve Maximum Frequency Stack on LeetCode (opens in a new tab)
10LFU CacheLeetCodeHard Solve LFU Cache on LeetCode (opens in a new tab)

Sign in to track your progress

Your checkboxes, streak and activity heatmap are saved to your account and sync across devices. It is free.
Sign in with email

New here? Create an account