Construct a directed graph of containing all characters as vertices.
Create an edge from each character to each character directly following that character in any word. For example, if you have a word @ % ^
, you’d have edges @ -> %
and % -> ^
.
Run a topological sort on the graph to get the correct order.
solved Figure out the order of a list of chars [closed]