educative.io

Solution doesn't find all the possible pairs

The solution given only produces one way.


Course: Grokking Coding Interview Patterns in Java - Learn Interactively
Lesson: Solution: Compilation Order - Grokking Coding Interview Patterns in Java

Hi @Sathvik_Reddi,

I hope you’re doing well!

The problem statement asks for a compilation order in which all of the classes can be compiled, given the dependency pairs. There can be more than one possible order, e.g., [[B, A], [C, A], [D, C], [E, D], [E, B]] can have [A ,B, C, D, E] and [A, C, B, D, E] as possible compilation orders. We are required to provide any valid compilation order, as the statement does not ask us to provide all possible orders.

As always, we appreciate our valued users reaching out to us. Therefore, please write to us if you have any further queries, concerns, or suggestions in general.

We hope you enjoy your experience with us at Educative! Happy learning!