(reqs: dict[str,list[str]])
| 2 | from collections import defaultdict |
| 3 | |
| 4 | def path(reqs: dict[str,list[str]]) -> str: |
| 5 | left, ans = sorted(reqs.keys()), "" |
| 6 | while left: |
| 7 | ans += next(x for x in left if not any(r in left for r in reqs[x])) |
| 8 | left.remove(ans[-1]) |
| 9 | return ans |
| 10 | |
| 11 | def part2(reqs: dict[str,list[str]]) -> int: |
| 12 | left, working, t = sorted(reqs.keys()), dict[str,int](), 0 |