Quant Memo
Coding/●●●●

Recover the alien alphabet

Asked at Two Sigma, Citadel

You are given a list of words that are sorted in lexicographic order according to some unknown alphabet. Derive a possible ordering of the distinct letters. If the input is self-contradictory, return "".

words = ["wrt", "wrf", "er", "ett", "rftt"]   ->   "wertf"

Return any valid letter order, or "" if none exists. Aim for O(C)O(C) where CC is the total number of characters.

Your answer

This one is open-ended. Work it through, then check your reasoning against the full solution.

More Coding questions