A new alien language uses the lowercase English letters a – z , but the order of the alphabet is unknown . You are given a list of words that is already sorted according to this alien order — that is, the list is in lexicographic order under the alien alphabet. Recover the order of the letters and return it as a string. If more than one order is consistent with the input, return any of them. If no order is consistent with the input, return an empty string . Only the letters that actually appear in words need to be ordered. How the order is inferred Compare each pair of adjacent words from left to right. The first position at which they differ tells you that the earlier word's letter comes before the later word's letter in the alien alphabet. Combining all of these pairwise relations lets you reconstruct the full order. Input format Each example's input is the function's argument list encoded as JSON. This problem takes a single argument — the array of words — so the input is shown as [[ wrt , wrf , er , ett , rftt ]] .