How would you solve a variant of the alien dictionary problem, and what edge cases would you watch for?
Implement the function below. Return the lexicographically smallest valid character ordering, or "" if the sorted words imply a cycle or an invalid prefix. Include every distinct character, including characters with no ordering constraints.
Input/output contract: words is a list of lowercase strings. The function returns a string containing each distinct character exactly once, or "" when no valid ordering exists.
def alien_order(words):