Alien Dictionary
HardProblem Description
There is a new alien language that uses the English alphabet, but the letter order is unknown.
You are given a list of words sorted lexicographically by that alien language. Derive a valid character order.
Return an empty string if:
- the input is invalid (prefix conflict), or
- the graph has a cycle.
Examples
Example 1:
Input: words = ["wrt","wrf","er","ett","rftt"]
Output: "wertf"
Example 2:
Input: words = ["z","x","z"]
Output: ""
Constraints
1 <= words.length <= 1001 <= words[i].length <= 100- All words contain lowercase English letters.
Hint
Build precedence edges from the first differing character of adjacent words, then topologically sort.
Solution
Test Results
Run tests to see the overall score, band, and section breakdown.
Public Tests
Detailed feedback for visible cases.
Public test details will appear here after you run your solution.
Hidden Tests
Summary only, with no hidden inputs or outputs.
Performance
Execution timing and pass/fail status.
No performance results yet.
AI Interviewer
I'll review your code once you submit it. I can also give you hints if you get stuck!