Directional beam coverage
A rooftop hub aims directional beams at relay towers. Tower i sits east[i] metres east and north[i] metres north of the hub, and negative values mean west or south. One beam covers a whole ray leaving the hub, so towers lying in the same direction share a beam however far out they are, while a tower in the exactly opposite direction needs a beam of its own. A tower recorded at the hub itself, zero east and zero north, is mounted on the hub and needs no beam. Given the two offset lists, which have the same length, return how many beams the hub must install so that every tower is covered.
beams_needed(east: list[int], north: list[int]) → int[[1,2,3],[2,4,6]]out1[[1,-1,0,0],[0,0,1,-1]]out4[[0,3],[0,0]]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,2,3],[2,4,6]]1not run yetsample[[1,-1,0,0],[0,0,1,-1]]4not run yetsample[[0,3],[0,0]]1not run yetsample