Skip to interview prep
Apexed
Problem list119 / 143

119. Measure Configuration Impact

MediumDependency graphs

Each dependency [service, prerequisite] allows a change at prerequisite to propagate to service. Services are numbered 0 to count - 1. Changes begin simultaneously at the services in changed.

An isolated service never starts, receives or forwards a change. Return the fewest propagation hops to each service in index order, with 0 for a non-isolated changed service and -1 for a service that cannot be reached.

Example 1

Input: count = 6, dependencies = [[1,0],[2,1],[2,4],[3,2],[5,3]], changed = [0,4], isolated = [3]
Output: [0,1,1,-1,0,-1]

Example 2

Input: count = 4, dependencies = [[1,0],[2,1],[0,2],[3,2]], changed = [0,0], isolated = []
Output: [0,1,2,3]

Constraints

  • 0 ≤ count ≤ 10,000 and at most 50,000 dependency pairs.
  • All IDs reference existing services. Dependencies can contain cycles.

Tab indents · Ctrl/⌘ + Enter runs · Esc then Tab leaves the editor

Run checks these cases; the expected output comes from the reference solution. Submit judges all 5 hidden and sample tests.

Code runs in an isolated browser sandbox. Progress and submissions are saved on this device.

Measure Configuration Impact — coding interview practice — Apexed