There is a foreign language that uses the English alphabet but with a different sort order. Given a list of words already sorted according to that alien language's rules, derive and return one valid ordering of the letters used, or an empty string if no valid order exists.
words = ["wrt","wrf","er","ett","rftt"]"wertf"words = ["z","x","z"]""Solve it in the editor. Sign in free to run your Python or JavaScript against test cases, get a verdict, and track your attempts.
Solve on FeatCode →Beyond basic traversal, some graph problems need ordering constraints (topological sort) or weighted shortest paths (Dijkstra, Bellman-Ford, minimum spanning trees).
Read the full Advanced Graphs guide →
Original problem on LeetCode ↗