A product tour visits every screen of an app exactly once, starting on screen 0. time[i][j] is how many seconds it takes to go from screen i to screen j (it may differ from time[j][i]). The tour does not need to return to screen 0.
Write shortestTour(time) that returns the least total time of a tour that starts at screen 0 and visits every screen exactly once.
Input: time = [[0,2,9,10],[1,0,6,4],[15,7,0,8],[6,3,12,0]] Output: 16
0 → 1 → 2 → 3 takes 2 + 6 + 8 = 16.
Input: time = [[0]] Output: 0
The tour is already done.
1 <= n <= 12time.length === n and every row has length ntime[i][i] === 0, and 0 <= time[i][j] <= 1000Run tries your code on the examples. Submit runs every test, including hidden edge cases, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #558 Shortest Tour Through Every Screen. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.