LeetCode – Course Schedule II (Java)
This is an extension of Course Schedule. This time a valid sequence of courses is required as output. Analysis If we use the BFS solution of Course Schedule, a valid sequence can easily be recorded. Java Solution public int[] findOrder(int numCourses, int[][] prerequisites) { if(prerequisites == null){ throw new IllegalArgumentException("illegal prerequisites array"); } int … Read more