Learn
Practice
Newsletter
Resources
Mobile
New
F
Toggle theme
0
F
0
Toggle menu
Animations
← Back to All Animations
Design Twitter
Bookmark
Input
Standard
Two Followees
Own Tweets Only
Custom
operations
=
[post(1,5), feed(1), follow(1,2), post(2,6), feed(1), unfollow(1,2), feed(1)]
time =
0
u1
no tweets
u2
no tweets
time =
0
u1
no tweets
u2
no tweets
getNewsFeed(1)
time =
1
u1
5
t0
u2
no tweets
candidates
5
t0
candidates = tweets[
u1
]
1
own tweet
getNewsFeed(1)
time =
1
u1
5
t0
u2
no tweets
candidates
5
t0
sort by
time
, newest first
follow(1, 2)
time =
1
u1
u2
follows
5
t0
u2
no tweets
following[u1]
+=
u2
getNewsFeed(1)
time =
2
u1
u2
follows
5
t0
u2
6
t1
candidates
5
t0
candidates = tweets[
u1
]
1
own tweet
getNewsFeed(1)
time =
2
u1
u2
follows
5
t0
u2
6
t1
candidates
5
t0
6
t1
candidates += tweets[
u2
]
total =
2
getNewsFeed(1)
time =
2
u1
u2
follows
5
t0
u2
6
t1
candidates
5
t0
6
t1
feed =
[6, 5]
getNewsFeed(1)
time =
2
u1
5
t0
u2
6
t1
candidates
5
t0
candidates = tweets[
u1
]
1
own tweet
getNewsFeed(1)
time =
2
u1
5
t0
u2
6
t1
candidates
5
t0
sort by
time
, newest first
time =
2
u1
5
t0
u2
6
t1
all operations processed
algo
master
.
io
Step:
Start: each user keeps their own tweet list stamped with a global time counter, plus a set of followees. getNewsFeed merges and sorts by recency.
0 / 15
Input
Standard
Two Followees
Own Tweets Only
Custom
operations
=
[post(1,5), feed(1), follow(1,2), post(2,6), feed(1), unfollow(1,2), feed(1)]
0 / 15
algo
master
.
io
Step:
Start: each user keeps their own tweet list stamped with a global time counter, plus a set of followees. getNewsFeed merges and sorts by recency.