You are given words, a list of lowercase words sorted according to the rules of an unknown alphabet. Work out an ordering of the letters that is consistent with that sorting and return it as a string.
- The result must contain every distinct letter that appears in
words, each exactly once - If several orderings are consistent, return any of them
- If the input is impossible, return the empty string
''. That covers a cycle in the deduced order, and also the invalid prefix case: ['abc', 'ab'] can never be sorted, because a prefix must come first - Letters inside a single word tell you nothing about their relative order