We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
I have a question about the test case 5: My solution always times out. It found the answer quickly, but it takes forever to exaust all searches using Dijkstra's algorithm. Here I have printed out the "searching depth for the minimal distance at the remaining searching paths". I have made sure that each path come back does not visit any location twice:
1 for -1 at 1,
2 for -1 at 34,
3 for 3278 at 241,
4 for 2175 at 471,
5 for 2175 at 3596,
6 for 689 at 375,
7 for 498 at 88,
8 for 498 at 126,
9 for 498 at 258,
10 for 498 at 481,
11 for 498 at 862,
12 for 498 at 1643,
13 for 437 at 1028,
14 for 437 at 1271,
15 for 432 at 1805,
16 for 417 at 1878,
17 for 417 at 2708,
18 for 417 at 4004,
19 for 417 at 5949,
20 for 417 at 8714,
21 for 417 at 12577,
22 for 417 at 18384,
23 for 417 at 26735,
24 for 417 at 38618,
25 for 417 at 55602,
26 for 417 at 79633,
27 for 417 at 114289,
The problem is that I can keep on traveling to all route which are less than 417 forever.
32 for 417 at 660905
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Jack goes to Rapture
You are viewing a single comment's thread. Return to all comments →
I have a question about the test case 5: My solution always times out. It found the answer quickly, but it takes forever to exaust all searches using Dijkstra's algorithm. Here I have printed out the "searching depth for the minimal distance at the remaining searching paths". I have made sure that each path come back does not visit any location twice: 1 for -1 at 1, 2 for -1 at 34, 3 for 3278 at 241, 4 for 2175 at 471, 5 for 2175 at 3596, 6 for 689 at 375, 7 for 498 at 88, 8 for 498 at 126, 9 for 498 at 258, 10 for 498 at 481, 11 for 498 at 862, 12 for 498 at 1643, 13 for 437 at 1028, 14 for 437 at 1271, 15 for 432 at 1805, 16 for 417 at 1878, 17 for 417 at 2708, 18 for 417 at 4004, 19 for 417 at 5949, 20 for 417 at 8714, 21 for 417 at 12577, 22 for 417 at 18384, 23 for 417 at 26735, 24 for 417 at 38618, 25 for 417 at 55602, 26 for 417 at 79633, 27 for 417 at 114289,
The problem is that I can keep on traveling to all route which are less than 417 forever.
32 for 417 at 660905