Fewest boosters to lift nodes
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.
min_boosters(uplink: list[int], reach: int) → int[[-1,0,1,0,3],1]out2[[-1,0,0,0],1]out1State 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.
[[-1,0,1,0,3],1]2not run yetsample[[-1,0,0,0],1]1not run yetsample