Alien Dictionary
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 language's dictionary, where the strings in words are sorted lexicographically by the rules of this new language. Return a string of the unique letters in the new alien language sorted in lexicographically increasing order by the new rules. If there is no solution, return "".

30:00

Alien Dictionary
hard
Topics
Companies

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 language's dictionary, where the strings in words are sorted lexicographically by the rules of this new language. Return a string of the unique letters in the new alien language sorted in lexicographically increasing order by the new rules. If there is no solution, return "".

Example 1:
Input: ["wrt","wrf","er","ett","rftt"]
Output: wertf
Constraints:
  • 1words.length1001 \leq \text{words.length} \leq 100

  • 1words[i].length1001 \leq \text{words}[i].\text{length} \leq 100

  • words[i] consists of lowercase English letters.

Input
arr =["wrt","wrf","er","ett","rftt"]

Start

e

f

r

t

w

Variables
No variables to display
DepthFunction Call
Stack empty
0/21