HardGraphs · Topological Sort

Alien Dictionary

The words are sorted by an unknown alien letter order. Return the letters in that order (any valid one), or "" if no order could produce this sorting.

["z","o"] → "zo"["hrn","hrf","er","enn","rfnn"] → "hernf"["abc","ab"] → ""

Try:
CALL
1 / 1

Code

The highlighted line runs next. The pill shows the live values in the running call.

Variables

The data structures the code is building

Words and letter rules

Left: the words being compared. Right: rules a → b (a comes first)

Time and space complexity

N = total characters, V = distinct letters, E = rules. The highlighted row is the solution being traced.

Keyboard: ← → step, Space play or pause. Up to 8 words of up to 8 lowercase letters, at most 9 different letters.