Solution: Compilation Order
Explore how to use topological sort to determine the correct order for compiling classes with dependencies. Understand building graph representations, managing in-degree counts, and traversing the graph to produce a valid compilation sequence. Learn to detect cycles that invalidate ordering and analyze time and space complexity of the solution.
Statement
There are a total of classes labeled with the English alphabet (, , , and so on). Some classes are dependent on other classes for compilation. For example, if class extends class , then has a dependency on . Therefore, must be compiled before .
Given an array of the dependency pairs, find the order in which the classes should be compiled.
Constraints:
- Class name should be a character.