Back to problems

Infer an Alien Alphabet from Sorted Words

Algorithm · ByteDance · Hard

You are given a list of non-empty strings words that are already sorted lexicographically according to the rules of an unknown alien alphabet. The alphabet contains only lowercase English letters, and every distinct character that appears in words belongs to this alphabet. From the sorted list, reconstruct the order of the alien alphabet. Return a string containing each distinct character exactly once. If the given ordering is inconsistent and no valid alphabet exists,…

Checking your access…