Hard · Graphs
Alien Dictionary
Given a list of words claimed to be sorted in an alien alphabet's lexicographic order, return a string of the distinct letters that appear in the words, ordered so that the list is sorted under that order (any valid order is accepted), or "" if no letter order sorts the list.
Examples
Example 1
{
"words": ["wrt", "wrf", "er", "ett", "rftt"]
}Output: "wertf"
Example 2
{
"words": ["abc", "ab"]
}Output: ""
Rebuild it in the studio
Open every published interview problem, solution, scene, and memory room free, with no account.