Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Execute Async Tasks in Dependency Graph
00:00
5 left

Execute Async Tasks in Dependency Graph

HardPython

Problem

Given a dependency graph where each node is a async task. A,B can run at the same time. C needs to wait for A and B to be done D needs C to be done Implement executeAsync interface to generate right order

Asked in the first round stage for a Senior Frontend Engineer role at NVIDIA, focusing on JavaScript async coding.

Implement the equivalent Python function execute_async(dependencies). The input is a dictionary mapping each task name to its direct prerequisites. Return a list of execution waves, where tasks in the same wave can run concurrently. Assume the graph is a DAG.

Constraints

  • Each task appears exactly once as a dictionary key.
  • Every prerequisite is another task in the graph.
  • The graph is a directed acyclic graph.
  • Task names are unique strings.
  • The graph may be empty.

Function Signature

def execute_async(dependencies):
Interviewer

Your question is Execute Async Tasks in Dependency Graph. Start with the requirements in the Question tab.

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.
CodePython 3
You need to log in / sign up to run or submit.Ln 2
Run your code to see test output here.