Two-phase commit outcome
A coordinator runs two-phase commit across participants. In the prepare phase each participant votes: 'yes', 'no', or 'timeout' (no reply within the window). The protocol commits ONLY if every participant voted 'yes'; if any participant voted 'no' or 'timeout', the coordinator aborts. Given the list of votes, return 'commit' or 'abort'. An empty participant set commits (vacuously, nothing to coordinate).
Implement
two_phase_decision(votes: list[str]) → strExamples
in
[["yes","yes","yes"]]out"commit"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 20 min
solution.py
InputExpectedGot
[["yes","yes","yes"]]"commit"not run yetsample