Fewest boosters to lift nodes
Your task
A fibre network runs out from a single head end and its layout is a tree. Node 0 is the head end and uplink[0] is -1. For every other node i, uplink[i] names the node it hangs off, always a smaller number. A booster placed on a node lifts the signal on that node and on every node within reach hops of it, counting hops along the fibre in either direction. Return the fewest boosters that leave every node lifted. uplink may be empty, in which case no boosters are needed, and reach may be 0. Serving the most unlifted nodes you can with each booster is not the fewest.
Examples
min_boosters(uplink: list[int], reach: int) -> intExample 1
Input
min_boosters([-1, 0, 1, 0, 3], 1)Output
2Example 2
Input
min_boosters([-1, 0, 0, 0], 1)Output
1