Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
Try to think of it as a graph problem. It will be impossible to study all the courses if the graph had a cycle.
The graph is a directed acyclic graph (DAG). The answer is the longes path in this DAG.
You can use DP to find the longest path in the DAG.