Package install order

Write codeMedium25 minGoogle and Microsoft style

Your task

A package manager must compute an install order. You're given a list of package names and a list of dependency pairs [a, b] meaning package a depends on b (so b must be installed before a). Return a valid install order such that every dependency is installed before the package that needs it. When several packages are simultaneously installable, install the lexicographically smallest first to make the result deterministic. If the dependencies contain a cycle (no valid order exists), return an empty list. Dependency pairs referencing unknown packages are ignored.

Examples

install_order(packages: list[str], deps: list[list[str]]) -> list[str]
Example 1
Inputinstall_order(["app", "lib", "core"], [["app", "lib"], ["lib", "core"]])
Output["core", "lib", "app"]