A design interview becomes concrete when the interviewer asks what happens on the second request, the wrong owner or a circular dependency. A diagram alone doesn't answer those questions. A small runnable model can expose whether the proposed invariant survives them.
This medium set combines earlier language and domain techniques on fresh records. You check a lock-order risk, a versioned key, guarded transitions, ownership, constrained allocation and deterministic dependency order. Explain the assumption the model makes before implementing it. The tasks don't start threads, operate elevators or call a remote service. They check the decision boundary those systems would depend on, including a null result when no valid complete answer exists.
import json
def process_payload(payload: str) -> str:
data = json.loads(payload)
graph = {}
for left, right in data:
graph.setdefault(left, []).append(right)
graph.setdefault(right, [])
active, done = set(), set()
def visit(node):
if node in active:
return True
if node in done:
return False
active.add(node)
if any(visit(child) for child in graph[node]):
return True
active.remove(node)
done.add(node)
return False
result = any(visit(node) for node in graph)
return json.dumps(result)
A cycle in directed acquisition dependencies creates a circular wait risk. A node currently on the DFS path differs from a node whose descendants are already finished. With adjacency lists, each node and edge is examined at most once.