Tick the in-degree down
Warm-up · Trace the algorithm · about 3 min
Node 3 has three incoming edges: from 0, 1 and 2. Kahn's algorithm has just taken 0 from the queue. Its first edge goes to 3. What does the in-degree of 3 drop to?
Example 1
Input:
{"edges":[[0,3],[0,1],[1,3],[2,3],[3,4]]}
Output:
2
Constraints
- Answer with a number.
Learn the idea first: Topological sort: Kahn's algorithm and DFS finishing order, a visual lesson.
More Topological sort: Kahn's algorithm and DFS finishing order problems
- Topological order Warm-up
- From finishing order to topological order Standard
- Course schedule II Standard
- Build order with dependencies Standard
- Alien dictionary Challenge