Dependent Microservices Deployment Problem
Dependent Microservices Deployment Problem — ExecCode Hard DSA Practice
Solve the Dependent Microservices Deployment problem on ExecCode. Free online hard DSA practice in Graph. Write and run code in Java, C++, Python — no signup required to run.
Problem description
An AWS deployment contains numservices microservices numbered from 0 through numservices - 1. Some services must be deployed before others. Each entry [a, b] in dependencies means service b must be deployed before service a. In graph terms, the pair creates a directed edge from b to a. Return true if there is an order that deploys every service while satisfying all dependencies. Return false if a directed cycle makes this impossible. You are given: num_services — the number of microservices dependencies — prerequisite pairs [service, prerequisite] Services with no prerequisites may be deployed at any time. An empty dependency list is deployable. A self-dependency such as [0, 0] is a cycle.
Examples
Input {'numservices': 5, 'dependencies': [[1, 0], [2, 0], [3, 1], [3, 2], [4, 3]]}; Output True. Input {'numservices': 4, 'dependencies': [[1, 0], [2, 1], [0, 2], [3, 1]]}; Output False. Input {'num_services': 6, 'dependencies': [[1, 0], [1, 0], [2, 1], [4, 3], [5, 4], [3, 5]]}; Output False
Constraints
0 <= numservices <= 100000\n- 0 <= dependencies.length <= 200000\n- 0 <= a, b < numservices for every dependency [a, b]\n- Duplicate dependency pairs may appear
Practice Dependent Microservices Deployment free on ExecCode. Browse DSA problems, topic map, and placement guides.