PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Coding & Algorithms/Netflix

Return valid task order from prerequisites

Last updated: Mar 29, 2026

Quick Overview

This question evaluates proficiency in graph algorithms, notably topological sorting and cycle detection, as well as algorithmic complexity analysis and handling of dependency constraints.

  • medium
  • Netflix
  • Coding & Algorithms
  • Software Engineer

Return valid task order from prerequisites

Company: Netflix

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

You are given **N** tasks labeled `0..N-1` and a list of directed dependency pairs `[(a,b), ...]` meaning **task `a` must be done before task `b`**. 1) Return **one valid execution order** of all tasks that satisfies all dependencies. 2) If it is **impossible** (the graph has a cycle), return an empty list. Follow-ups that may be asked: - If multiple valid orders exist, return the **lexicographically smallest** order. - Return **all** valid topological orders (if feasible for the input size). - State the **time and space complexity** of your approach. Constraints can be assumed typical for interview settings (e.g., up to 1e5 nodes/edges for part 1; much smaller for “all orders”).

Quick Answer: This question evaluates proficiency in graph algorithms, notably topological sorting and cycle detection, as well as algorithmic complexity analysis and handling of dependency constraints.

Related Interview Questions

  • Implement Cache, Undo, and DFS - Netflix
  • Implement Streaming Word Counter - Netflix (medium)
  • Implement TTL Cache and Tree Balance Reporting - Netflix (medium)
  • Implement ordering and undo executor - Netflix (medium)
  • Implement Caches, Undo, and Traversal - Netflix
Netflix logo
Netflix
Jan 30, 2026, 12:00 AM
Software Engineer
Onsite
Coding & Algorithms
7
0

You are given N tasks labeled 0..N-1 and a list of directed dependency pairs [(a,b), ...] meaning task a must be done before task b.

  1. Return one valid execution order of all tasks that satisfies all dependencies.
  2. If it is impossible (the graph has a cycle), return an empty list.

Follow-ups that may be asked:

  • If multiple valid orders exist, return the lexicographically smallest order.
  • Return all valid topological orders (if feasible for the input size).
  • State the time and space complexity of your approach.

Constraints can be assumed typical for interview settings (e.g., up to 1e5 nodes/edges for part 1; much smaller for “all orders”).

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Netflix•More Software Engineer•Netflix Software Engineer•Netflix Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.