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

Question

Design a mini-Twitter. Operations in order: ['post', user, tweetId] (a global timestamp increments per post), ['follow', a, b] (a follows b), ['unfollow', a, b], and ['feed', user] which returns the 10 most recent tweet ids from the user and everyone they follow, newest first. A user always implicitly follows themselves. Return the list of feeds (each a list of tweet ids) for each 'feed' op.

Implement
design_twitter(ops: list[list]) → list[list[int]]
Examples
in[[["post",1,101],["feed",1],["follow",1,2],["post",2,201],["feed",1],["unfollow",1,2],["feed",1]]]out[[101],[201,101],[101]]
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.