Courier Tour Minimum Ledger
Preview mode. Log in to edit, run, submit, and save progress.
Hard
Courier Tour Minimum Ledger
A courier starts at hub 0, must visit every other hub exactly once, and must return to hub 0 at the end. The travel cost from hub i to hub j is provided in the cost matrix. The route must be a closed tour. Every hub must appear exactly once before returning to the start. Your task is to find the minimum total travel cost of such a tour. Input Format: You are given a square matrix cost. Output Format: Return the minimum possible closed-tour cost.
Examples
Example 1
Input:
cost = [[0, 10, 15, 20], [10, 0, 35, 25], [15, 35, 0, 30], [20, 25, 30, 0]]
Output:
80
Explanation: The cheapest tour is 0 -> 1 -> 3 -> 2 -> 0 with total cost 80. Therefore the output is 80.
Approach hint
Track visited desks as a bitmask.
Common mistake
Skipping assumptions, edge cases, or trade-offs can make an otherwise good answer feel incomplete.
solution.cpp