[leetcode]269. Alien Dictionary外星字典

时间:2023-03-10 07:27:22
[leetcode]269. Alien Dictionary外星字典

There is a new alien language which uses the latin alphabet. However, the order among letters are unknown to you. You receive a list of non-empty words from the dictionary, where words are sorted lexicographically by the rules of this new language. Derive the order of letters in this language.

Example 1:

Input:
[
"wrt",
"wrf",
"er",
"ett",
"rftt"
] Output: "wertf"

题目

给定一组单词,已知这些单词的排列顺序是符合某种奇怪的字典序的。请求出这种字典序下各个字母的排列顺序,对于存在多种答案者,给出任一即可。

思路

代码