Fill the trip table
Warm-up · Trace the algorithm · about 6 min
Follow the trip table on three cities that start at city 0. Row labels are masks: bit k is 1 when city k is visited. Answer each question before the step plays.
Example 1
Input:
{"values":[[0,4,1],[4,0,2],[1,2,0]]}
Output:
3
Constraints
- The trace uses the distances shown.
- Every trip starts at city 0 and ends anywhere.
Learn the idea first: Bitmask DP: TSP and assignments, a visual lesson.
More Bitmask DP: TSP and assignments problems
- Which mask is it? Warm-up
- Shortest path visiting all nodes Standard
- Minimum cost assignment Standard
- Count valid subsets Standard