Apply topological sort


Make the graph using edges in the form of B[i]->C[i].
Now apply topological sort and maintain the index of each and every course alongside in an unordered map.
Iterate over each index again and see whether index of B[i] < index of C[i] , if no then return false.
Otherwise return true .