python
advanced
हल किया
2026-11-24 को समाप्त
Build order (topological sort)
A build system knows which tasks depend on which: deps["deploy"] = ["test", "build"] means test and build must run before deploy. Write build_order(deps) that returns a list with every task exactly once, each after all of its dependencies.
- Tasks that only appear as dependencies are tasks too.
- When several tasks are ready at the same time, take them in alphabetical order, so the result is deterministic.
- If there is a cycle, raise
ValueErrorwhose message names the tasks in the cycle (any order is fine, e.g."cycle: a, b, c").
Acceptance criteria
- The tests at the bottom print
All tests passed.
Hint: Kahn's algorithm with a heapq of ready tasks.
अब तक 0 लोगों ने हल किया।
एडिटरCtrl + Enter
जब टेस्ट "All tests passed" दिखाते हैं, तो चैलेंज इस ब्राउज़र में हल के रूप में चिह्नित हो जाता है।
अपना समाधान समीक्षा के लिए भेजें