Solution: Compilation Order
Explore how to solve class compilation order problems by applying topological sort. This lesson helps you understand dependency graphs, build adjacency lists, track in-degrees, and use a breadth-first search approach to find valid compilation sequences, ensuring you can detect cycles and optimize your solution's time and space complexity.
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 a list of the dependency pairs, find the order in which the classes should be compiled.
Constraints:
- Class name should be a character.