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.
- Prepare
- Algorithms
- Graph Theory
- Jeanie's Route
- Discussions
Jeanie's Route
Jeanie's Route
Sort by
recency
|
26 Discussions
|
Please Login in order to post a comment
Java solution. First, remove outer, non-letter cities (will never be visited). Then, from the (new) outer letter cities, go inward until you reach an intersection city (3 or more edges) and calculate the minimum and maximum subtree value. You can consider a 'minimum' subtree is where you start or end a path at that subtree. A maximum subtree will double value of all "lines" in the subtree. Eventually, you will reach an inner city in which all subtrees are calculated. From there you can calculate an intersection's cities minimum path will add two minimum subtrees with the rest as maximum subtrees. Once you've reached the most inner intersection city, you can calculate it's minimum path and move back outerwards to calcuate the rest of the intersections minimum paths (with optimizations). One of the intersections will have the minimum path, and that's what you will return. Minimum is O(# cities), maximum is O(# cities + # edges).
python3
how can we know which city is must delivered or not ?? The thing we could know is the number of letter.. isn't it??
Here is my solution in java, javascript, python, C, C++, Csharp HackerRank Jeanie’s Route Problem Solution
Here is the solution of Jeanie's Route Click Here