Given a sorted list of words from an alien language, return a valid character ordering. Return an empty string if no valid ordering exists. Pattern focus: DFS Topological Order. This is the postorder/finish-time variant of the alien dictionary problem.
words = dictionary words sorted according to an alien alphabet
valid character order or an empty string
Example 1:
Input:
words = ["wrt","wrf","er","ett","rftt"]
Output:
wertf
Explanation:
The adjacent words imply the order w -> e -> r -> t -> f.
Example 2:
Input:
words = ["z","x"]
Output:
zx
Explanation:
The first word before the second gives z < x.
Example 3:
Input:
words = ["z","x","z"]
Output:
Explanation:
The constraints create a cycle, so there is no valid order.