Code RoomAlien dictionary order
HardPrep Room Coding #78

Alien dictionary order

CodingAlgorithms & data structuresSenior–Staff~40 min

You are given a list of words sorted lexicographically according to an unknown alphabet of lowercase letters. Derive an order of the letters that is consistent with the sorting, and return it as a string. If multiple valid orders exist, return the one that is lexicographically smallest by normal English letter order among available choices at each step. Return an empty string if no valid order exists (the input is internally contradictory, including the case where a longer word precedes its own prefix).

Implement
alien_order(words: list[str]) → str
Examples
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 40 min
InputExpectedGot
[["wrt","wrf","er","ett","rftt"]]"wertf"not run yetsample