Code Room
CodingMediumcod-g1102
Subject Sloppy quorum with hinted handoff replica selectionLevel Mid–Senior~28 minCommon in Distributed systems interviewsIndustries Technology

Question

A Dynamo-style write needs W acknowledgements. The preference list `pref_list` is the ordered list of node ids that should hold this key (length >= W). Some nodes are down: `alive` is the set (given as a list) of node ids currently reachable. Under sloppy quorum, the coordinator walks the preference list in order, sending to each alive node until it has W acks; if it cannot get W acks from the preference list alone, it falls back to `fallback` nodes (an ordered list, walked in order) which accept hinted handoff. Return the ordered list of node ids that ultimately receive the write (those chosen, in selection order). If even using all alive preference + fallback nodes you cannot reach W, return the ids gathered so far (a partial, failed write).

Implement
sloppy_quorum_targets(pref_list: list[str], alive: list[str], fallback: list[str], w: int) → list[str]
Examples
in[["A","B","C"],["A","B","C"],["D","E"],2]out["A","B"]
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.