An AMD ROCm build pipeline contains tasks such as kernel compilation, linking, testing, and packaging. Each dependency is given as [prerequisite, task], meaning the prerequisite must be completed before the task.
Implement dependency_order(tasks, dependencies) to return the lexicographically smallest valid completion order. If the dependency graph contains a cycle, return an empty list because no valid order exists. Tasks with no dependencies must still appear in the result. Duplicate dependency pairs should be treated as one dependency.
tasks: a list of unique strings representing all tasks.dependencies: a list of two-element lists [prerequisite, task].[] if a cycle exists.def dependency_order(tasks, dependencies):