Question
An operating system tracks a wait-for graph among n processes labeled 0..n-1. Each edge [a, b] means process a is blocked waiting for a resource currently held by process b. A deadlock exists if and only if there is a cycle in this directed graph. Return True if the system is deadlocked, otherwise False. The graph may have many edges and may be disconnected; self-loops [a, a] count as a deadlock.
has_deadlock(n: int, waits: list[list[int]]) → bool[3,[[0,1],[1,2],[2,0]]]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.