Your question is Graph Traversal and Shortest Path. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Redesign Health is evaluating care journeys across services such as intake, clinical review, diagnostics, and treatment. Given a directed graph of service transitions, find the minimum total transition time from a starting service to a destination when one transition may use a virtual-care credit and therefore cost zero minutes.
You may use the credit at most once, or not use it. Return both the minimum time and the corresponding sequence of service IDs. If the destination cannot be reached, return [-1, []].
Implement fastest_care_path(n, edges, start, end), where n is the number of services labeled 0 through n - 1, and each edges entry is [from_service, to_service, minutes]. Edges are directed, and multiple edges between the same services are allowed. Return [minimum_minutes, path], where path is a list of service IDs from start to end.
def fastest_care_path(n, edges, start, end):