You have been given a sorted (lexical order) dictionary of an alien language. Write a function that finds the order of characters in the alien language. This dictionary will be given to you in the form of an array of strings called 'dictionary,' of size 'N.'
If the dictionary consists of the following words:-
["caa", "aaa", "aab"]
then, the order of alphabets are -
['c', 'a', 'b']
If the language consists of four letters, the four letters should be the starting four letters of the English language. However, their order might differ in the alien language.
Sample Input 1 :
a aa aaa
a b c
Sample Output 1 :
Explanation For Sample Output 1 :
For the first test case, the words are 'a', 'aa', and 'aaa'. Since the only unique character here is 'a', so the array to be returned will just be ['a']. The 'true' that is being printed just signifies that the output returned by the function is valid.
For the second test case, the words are 'a', 'b', and 'c'. The unique characters here are 'a', 'b', and 'c' (in that order), so the array to be returned will be ['a', 'b', 'c']
Sample Input 2 :
caa aaa aab
Sample Output 2 :