Product
Pricing
Blog
Forum
NEW
Referral
Description
Solution
Discussion
Submissions
Ask AI
AI Insights
Quick Summary
Model task dependencies as a directed graph where edges indicate prerequisite relationships.
Group tasks into parallel execution batches by processing nodes with zero remaining prerequisites level-by-level.
Return an empty list if a cycle prevents all tasks from being scheduled.
What This Tests
Directed graph modeling and adjacency list construction
Topological sorting via Kahn's algorithm
Cycle detection in directed graphs
Level-order traversal and batch processing
Lexicographical sorting within dynamic groups
Common Patterns
Graph Traversal
BFS
Sorting
Collapse
Hint 1
Hint 2
What Interviewers May Ask Next
Report
Report seen similar question in interview
Ask AI Assistant
Ask AI Assistant
Ask me anything about this coding question!
python
Auto
Debug
Run
Submit
Test Cases
Input
Output
Expected