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.
- Jack goes to Rapture
- Discussions
Jack goes to Rapture
Jack goes to Rapture
Sort by
recency
|
16 Discussions
|
Please Login in order to post a comment
Kotlin solution similar to Dijkstra's algorithm with different distance calculation (weights are not cumulative like in the traditional problem)
Java Dijkstra's Algorithm O((gEdges+gNodes)loggNodes)
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
Prim's Algorithm and heap
Similar to the leetcode 778 Swin in Rising Water. The core of the question is to minimize the maximum cost (the cost between 2 nodes along the path) from source to destination.