Code Room
CodingHardcod-g588
Subject Design data structuresLevel Senior–Staff~40 minCommon in Algorithms & data structures interviewsIndustries Software development, Technology

Question

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.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.