Alien Dictionary
Examples
Example 1:
Input: ["z","o"]
Output: "zo"
Explanation:
Example 2:
Input: ["hrn","hrf","er","enn","rfnn"]
Output: "hernf"
Explanation:
Example 1:
Input: ["z","o"]
Output: "zo"
Explanation:
Example 2:
Input: ["hrn","hrf","er","enn","rfnn"]
Output: "hernf"
Explanation:
There is a foreign language which uses the latin alphabet, but the order among letters is not "a", "b", "c" ... "z" as in English.
You receive a list of non-empty strings words from the dictionary, where the words are sorted lexicographically based on the rules of this new language.
Derive the order of letters in this language. If the order is invalid, return an empty string. If there are multiple valid order of letters, return any of them.
A string a is lexicographically smaller than a string b if either of the following is true:
a than in b.a is a prefix of b and a.length < b.length.From "z" and "o", we know 'z' < 'o', so return "zo".
words will contain characters only from lowercase 'a' to 'z'.1 <= words.length <= 1001 <= words[i].length <= 100