Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Dependency Chain Status Query

MediumPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Dependency Chain Status Query. 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.

You need to log in / sign up to run or submit.

Problem

Can you explain how to build a dependency chain and query the status along that chain?

Implement the task as a function that returns every prerequisite of a target node followed by the target, with each node's status. The dependency graph is directed from a node to its immediate prerequisites, and the graph is guaranteed to be acyclic.

Input: a dependency dictionary, a status dictionary, and a target node. Output: a list of dictionaries in prerequisite-first order, each containing node and status.

Constraints

  • 1 <= number of reachable nodes <= 1000
  • The dependency graph is directed and acyclic
  • Every referenced node has an entry in statuses
  • Dependency lists contain node names represented as strings
  • The target node may have no prerequisites

Function Signature

def dependency_chain_status(dependencies, statuses, target):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output