Find max zone overlap

Write codeHard40 min

Your task

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.

Examples

peak_zone_stack(lefts: list[int], bottoms: list[int], rights: list[int], tops: list[int]) -> int
Example 1
Inputpeak_zone_stack([0, 1], [0, 1], [3, 4], [3, 4])
Output2
Example 2
Inputpeak_zone_stack([0, 3], [0, 0], [3, 6], [3, 3])
Output1
Example 3
Inputpeak_zone_stack([0, 2, 1], [0, 1, 2], [5, 6, 4], [5, 4, 6])
Output3