← All problems

Alien Dictionary

Hard graphstopological-sort LeetCode ↗
Derive the character order from a list of words sorted in an alien language.

Hints (0/3 revealed)

Log in to reveal hints progressively.

Complexity

Time O(C), Space O(1) (fixed alphabet)

Common pitfalls

  • Missing the prefix-invalid case
  • Using only first/last words

Your solution

Log in to save your code and track progress.