Alien Dictionary
Write the code, see it run, pass the checks.
The problem
- hard
- Code
- Pro
Write alienOrder(words). An alien language uses lowercase English letters in an unknown order, and words is a list of its words sorted the way a dictionary is: two words compare at their first differing letter, and if one is the start of the other, the shorter comes first. Return a string holding every letter that appears in words exactly once, in an order the list agrees with. When several orders fit, any of them is fine. If none fits, return an empty string. For example, ["wrt", "wrf", "er", "ett", "rftt"] gives "wertf".
Your code must pass
- Finds an order the sorted list agrees with
- Includes every letter, even ones with no rule
- Returns an empty string for contradicting rules
- Returns an empty string when a word comes before its own start