Find max zone overlap
A level editor lets designers drop rectangular trigger zones on a map. Zone i catches every point whose horizontal position is at least lefts[i] and below rights[i] and whose vertical position is at least bottoms[i] and below tops[i], so two zones sharing only an edge never stack. A zone with no width or no height catches nothing. Zones arrive unsorted, coordinates reach a billion either way and there can be 2000 zones, so neither walking the map cell by cell nor testing every candidate point against every zone will finish in time. The engine warns when too many zones fire together. Return the largest number of zones catching any single point of the map, or 0 when nothing is caught.
peak_zone_stack(lefts: list[int], bottoms: list[int], rights: list[int], tops: list[int]) → int[[0,1],[0,1],[3,4],[3,4]]out2[[0,3],[0,0],[3,6],[3,3]]out1[[0,2,1],[0,1,2],[5,6,4],[5,4,6]]out3State 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.
[[0,1],[0,1],[3,4],[3,4]]2not run yetsample[[0,3],[0,0],[3,6],[3,3]]1not run yetsample[[0,2,1],[0,1,2],[5,6,4],[5,4,6]]3not run yetsample