There is a new alien language that uses the English alphabet. However, the order of the letters is unknown to you.
You are given a list of strings `words` from the alien language's dictionary, where the strings are **sorted lexicographically** by the rules of this new language.
Derive the order of letters in this language. If no valid ordering exists, return an empty string. If there are multiple valid orderings, return the lexicographically smallest one.
**Note:** If a longer word appears before a shorter word that is its prefix (e.g., "abc" before "ab"), the input is invalid and you should return an empty string.
Example 1
Input:words = ["wrt","wrf","er","ett","rftt"]
Output:"wertf"
Explanation:From the input: w < e, r < t, t < f, e < r. So the order is w, e, r, t, f.
Example 2
Input:words = ["z","x"]
Output:"zx"
Example 3
Input:words = ["z","x","z"]
Output:""
Explanation:The order is invalid because z cannot be both before and after x.
Constraints
- 1 <= words.length <= 100
- 1 <= words[i].length <= 100
- words[i] consists of only lowercase English letters.