Solved LeetCode program · 180 of 1,000
#0207 · Course Schedule
Original English source
The size is 2. The edges is a list of 1 and 0. The pairs is 1. The adjacency is a list of 4 zeros. The indegree is a list of 2 zeros.
For every edge from 0 to pairs minus 1.
The target is item (edge times 2) of edges. The origin is item (edge times 2 plus 1) of edges. Set item (origin times size plus target) of adjacency to 1. Increase item target of indegree by 1.
The queue is an empty list of whole numbers. The count is 0. The head is 0.
For every node from 0 to size minus 1.
If item node of indegree is 0, Place node into queue, add 1 to count.
The seen is 0.
Repeat while head is less than count.
The node is item head of queue. Add 1 to head. Add 1 to seen.
For every next from 0 to size minus 1.
If item (node times size plus next) of adjacency is 1.
Decrease item next of indegree by 1. If item next of indegree is 0, Place next into queue, add 1 to count.
If seen is size, show true, otherwise show false.
Expected stdout
true