Question
Detect whether a set of transactions is deadlocked given a wait-for graph. Input is a list of (a, b) edges meaning transaction a is waiting for a resource held by transaction b. A deadlock exists if and only if this directed graph contains a cycle. Return True if any cycle exists, else False. Node labels are arbitrary hashable values; an edge may appear more than once; self-loops (a waits for itself) count as a cycle. The edge list may be empty.
has_deadlock(edges: list[tuple]) → bool[[["t1","t2"],["t2","t3"],["t3","t1"]]]outtrueState 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.