Problem context and objectives
Mission briefing
Puzzle systems engineer · A game mechanic is behaving incorrectly
Merge the newest posts from followed authors: The Signal Feed.
Brute force may pass the demo but fail when the world fills with players.
How you win
- 1Recognize when Social feed design matches the clues
- 2Keep this true after every move: feed candidates come only from the user or currently followed authors
- 3Reach the result within O(P log P) simple query, improvable with a heap merge
Rules and pressure
- Target cost: O(P log P) simple query, improvable with a heap merge
- State rule: feed candidates come only from the user or currently followed authors
Lesson 1 of 3
Live algorithm trace
Social feed design
Complete execution1 of 5
0
post 1:5
op
1
follow 1:2
2
post 2:6
3
feed 1
4
unfollow 1:2
User 1 publishes post 5 at the first sequence.
1
append each post with increasing sequence2
follow adds an author to the user's set3
unfollow removes that author4
feed includes the user plus current follows5
collect their post candidates6
return at most ten newest idssequence = 1posts1 = 5
Truth to preserve / Cost target
Truth to preserve
feed candidates come only from the user or currently followed authors
Cost target
O(P log P) simple query, improvable with a heap merge
Store follow relationships and timestamped posts. A feed query gathers posts from the user and followed authors, then returns the ten newest by global sequence.
Your call · What should guide every step of this algorithm?