Derive ordering constraints from adjacent words, then topologically sort characters.
(w1, w2), find first differing char a != b and add edge a -> b.w1 starts with w2 but w1 is longer, return "".Adjacent-word comparisons provide the minimal necessary constraints; topo sort yields a valid character order iff constraints are acyclic.
Derive ordering constraints from adjacent words, then topologically sort characters.
(w1, w2), find first differing char a != b and add edge a -> b.w1 starts with w2 but w1 is longer, return "".Adjacent-word comparisons provide the minimal necessary constraints; topo sort yields a valid character order iff constraints are acyclic.