Monorepo tree height
A monorepo build tool describes a release as a list of edges. Every entry of edges is one string written parent>child, meaning the module named before the marker pulls in the module named after it directly. The edges arrive in whatever order the scanner emitted them, so the root is not always mentioned first. The structure is a tree: exactly one module is never listed as a child, and every other module is listed as a child exactly once. Module names are non empty and never contain the marker character. Compilation walks down from the root, so the team wants the module that sits furthest from it. Return the name of the module at the greatest distance from the root, counting the root itself as distance 0. If several modules tie at that greatest distance, return whichever of them sorts first alphabetically. Return an empty string when edges is empty.
deepest_build_target(edges: list[str]) → str[["app>core","app>ui","core>utils"]]out"utils"[["r>a","r>b"]]out"a"[["y>x","z>y"]]out"x"State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
[["app>core","app>ui","core>utils"]]"utils"not run yetsample[["r>a","r>b"]]"a"not run yetsample[["y>x","z>y"]]"x"not run yetsample