Future dependency resolution graph
Resolve a graph of futures. nodes is a list of [id, kind, deps, latency]. kind is 'value' (an immediately-available leaf, deps empty) or 'combine' (resolves only after ALL of its deps resolve). A 'value' node resolves at time = latency. A 'combine' node resolves at time = (max of its deps' resolution times) + latency. There are no cycles. Return the list of [id, resolution_time] sorted by resolution_time ascending, breaking ties by ascending id.
Implement
resolve_futures(nodes: list[list]) → list[list]Examples
in
[[[1,"value",[],5],[2,"value",[],3],[3,"combine",[1,2],2]]]out[[2,3],[1,5],[3,7]]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 30 min
solution.py
InputExpectedGot
[[[1,"value",[],5],[2,"value",[],3],[3,"combine",[1,2],2]]][[2,3],[1,5],[3,7]]not run yetsample