You are given a list of words sorted in lexicographic order according to an unknown ("alien") alphabet.
Return one valid ordering of the unique characters in this alien alphabet that is consistent with the given sorted word list. If no valid ordering exists, return an empty string.
words
is already sorted according to the alien alphabet.
words
: an array of strings, length
n
.
""
if impossible.
1 <= n <= 10^4
1 <= len(words[i]) <= 100
word1
is a strict prefix of
word2
, then
word1
must appear before
word2
in the sorted list (otherwise the ordering is invalid).
Input: words = ["wrt", "wrf", "er", "ett", "rftt"]
Possible output: "wertf"