Coding Challenge

Alien Dictionary

Hard
graphtopological-sortstring

Infer a character ordering from a sorted alien dictionary.

Given words sorted according to an unknown alphabet, return a valid character ordering or an empty string if the ordering is invalid.

Examples

Input: words = ["wrt","wrf","er","ett","rftt"]

Output: "wertf"

Constraints

  • Words are already sorted according to alien rules

Preparing your coding workspace...