Alien Dictionary
Hard
Advanced Graphs
NeetCode 150
There is a new alien language that uses the English alphabet. However, the order among the letters is unknown to you. You are given a list of strings words from the alien dictionary's sorted order. If it is not possible to determine the order of the alphabet, return "". If there are multiple valid solutions, return any of them. A string s is lexicographically smaller than a string t if at the first letter where s and t differ, the letter in s comes before the letter in the alphabet of t. If the first min(s.length, t.length) letters are the same, then s is smaller if and only if s.length < t.length.

Constraints:

  • 1 <= words.length <= 100
  • 1 <= words[i].length <= 100
  • words[i] consists of only lowercase English letters.