Code RoomSocial feed
HardPrep Room Coding #1155

Social feed

CodingAlgorithms & data structuresSenior–Staff~40 min

Design a mini social feed. Support operations replayed in order: ["post", userId, tweetId] records a tweet; ["follow", followerId, followeeId]; ["unfollow", followerId, followeeId]; ["feed", userId] which returns the 10 most recent tweet IDs (newest first) posted by the user or anyone they follow. A user implicitly follows themselves. Return the list of feed results (each a list of tweetIds) for every feed operation, in order.

Implement
mini_twitter(ops: list[list]) → list[list[int]]
Examples
in[[["post",1,5],["feed",1],["follow",1,2],["post",2,6],["feed",1],["unfollow",1,2],["feed",1]]]out[[5],[6,5],[5]]
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

0:00 of about 40 min
InputExpectedGot
[[["post",1,5],["feed",1],["follow",1,2],["post",2,6],["feed",1],["unfollow",1,2],["feed",1]]][[5],[6,5],[5]]not run yetsample