Alien dictionary order
You are given a list of `words` sorted according to the rules of an unknown alphabet. Derive a possible ordering of the distinct letters consistent with that sort. If several orderings are valid, return the lexicographically smallest one (treating letters by normal ASCII for the tie-break). Return the empty string if no valid ordering exists (the input is internally contradictory, e.g. a prefix appears after its extension).
Implement
alien_order(words: list[str]) → strExamples
in
[["wrt","wrf","er","ett","rftt"]]out"wertf"What a strong answer looks like
State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
0:00 of about 35 min
solution.py
InputExpectedGot
[["wrt","wrf","er","ett","rftt"]]"wertf"not run yetsample