Your question is Shortest Dependency Path in Microservices. 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.
In an SAP BTP microservices landscape, each service may call one or more other services. Given a directed dependency graph, find the shortest dependency path from a source service to a target service.
Return the path as a list of service names, including both endpoints. If the target cannot be reached, return an empty list. If multiple shortest paths exist, return any one of them.
Implement shortest_dependency_path(dependencies, source, target), where dependencies is a dictionary mapping a service name to a list of services it directly calls. source and target are strings. Return a list of strings representing the shortest directed path.
A dependency listed in the graph is directed: an edge from A to B means A depends on or calls B. Services with no outgoing dependencies may be absent from the dictionary.
def shortest_dependency_path(dependencies, source, target):