Alien Dictionary
Hard
Graphs
Topological Sort
Given sorted words in alien language, derive character order.
Input: words one per line
Output: character order string
Constraints
See problem-specific constraints. Optimized solution required.
Examples
Example 1:
Input: wrt
wrf
er
ett
rftt
Output:
Example 2:
Input: wrt
wrf
er
ett
rftt
Output:
Hints
Consider a topological sort approach.
Think about time complexity.
Tests:
Runtime:
Memory:
Test
Input:
Expected:
Got:
Click Run Code to test against sample cases, or Submit to test against all cases.
▲ Console