Solution: Compilation Order
Discover how to determine the correct compilation order of classes using topological sorting. This lesson guides you through building a graph of dependencies, finding sources with zero in-degree, and applying BFS to produce a valid order or detect cycles, preparing you to solve similar coding interview problems efficiently.
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.