Follow redirect chains
A link checker resolves the redirect table a documentation site ships before it publishes a release. Each entry of rules is written as a source path, a greater-than sign, then a target path, for example /old>/new, and every path begins with a slash. When two entries name the same source, the first entry wins. For each path in starts, follow the redirects, since a path with no rule is where a chain ends. Return one verdict per start in the same order. The verdict is the word loop when the walk arrives at a path it already visited, counting the start itself. It is the word limit when the walk is still standing on a path that has a rule after max_hops hops, so a chain that runs out of hops reports limit even when a loop lies further ahead. Otherwise the verdict is the final path.
redirect_chain_outcomes(rules: list[str], starts: list[str], max_hops: int) → list[str][["/intro>/getting-started","/getting-started>/guides/start","/old-faq>/faq"],["/intro","/faq","/old-faq"],5]out["/guides/start","/faq","/faq"][["/a>/b","/b>/c","/c>/a"],["/a","/b","/d"],10]out["loop","loop","/d"][["/1>/2","/2>/3"],["/1"],1]out["limit"]State 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.
[["/intro>/getting-started","/getting-started>/guides/start","/old-faq>/faq"],["/intro","/faq","/old-faq"],5]["/guides/start","/faq","/faq"]not run yetsample[["/a>/b","/b>/c","/c>/a"],["/a","/b","/d"],10]["loop","loop","/d"]not run yetsample[["/1>/2","/2>/3"],["/1"],1]["limit"]not run yetsample