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.
▲ Console

Install Talent Arabia

Get instant access to jobs and career tools on your device.