LC: 269. Alien Dictionary - spiralgo/algorithms GitHub Wiki

269. Alien Dictionary:

The Essence:

When we have some words like ["a", "b", "c", "cx", "cy"], what we can infer from here is that: c comes after b, b comes after a, y comes after x. This all should remind us of the successor relationship from directed graphs. So, if we can create a graph of these letter relationships, we can just apply topological sorting to it to get the lexicographical ordering.

Details:

Please refer to the corresponding PR for a detailed explanation and implementations:

https://github.com/spiralgo/algorithms/pull/367