Question
There are `num_courses` courses labeled `0` through `num_courses - 1`. Each prerequisite pair `(course, prerequisite)` states that the prerequisite must be completed first. Implement: ```python def can_finish(num_courses: int, prerequisites: list[tuple[int, int]]) -> bool: ... ``` Return whether it is possible to complete every course. Courses with no edges are valid, and duplicate prerequisite pairs should not change the answer. Aim for `O(V + E)` time. ## Staged follow-ups 1. Return one valid course order, or an empty list when none exists. 2. Return an explicit cycle to explain why the schedule is impossible. 3. Process prerequisite additions incrementally and reject an addition that creates a cycle.