197. Alien Dictionary
HardGraph
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 in words are sorted lexicographically by the rules of this new language. Derive the order of letters in this language, and return it. If there are multiple valid orderings, return any of them. If the order is invalid, return an empty string.
Examples
Input: ["wrt","wrf","er","ett","rftt"]
Output: wertf
Explanation: From the given order: w < e, t < f, r < t, e < r.
Constraints
- 1 <= words.length <= 100
- 1 <= words[i].length <= 100
- words[i] consists of only lowercase English letters.
Loading...
Run checks all cases above. Submit evaluates all test cases.