Amazon Interview Question

course schedule problem of graph in a different manner