Largest free region

Write codeHard40 min

Your task

A data centre floor is a width by height rectangle of one metre cells, with x running from 0 to width-1 and y from 0 to height-1. Racks arrive as a list of four integer rows x1, y1, x2, y2, and a rack occupies every cell with x1 <= x <= x2 and y1 <= y <= y2. Footprints may overlap and always sit inside the floor. A trolley rolls between orthogonally adjacent free cells, so free cells that touch edge to edge belong to the same region. Return the number of cells in the largest connected region of free cells, or 0 when the floor has no free cell at all. width and height reach one million, so nothing that touches every cell can finish, but there are at most 200 racks.

Examples

floor_open_area(width: int, height: int, racks: list[list[int]]) -> int
Example 1
Inputfloor_open_area(8, 6, [[2, 0, 2, 4], [5, 2, 6, 5]])
Output35
Example 2
Inputfloor_open_area(4, 4, [])
Output16
Example 3
Inputfloor_open_area(6, 6, [[0, 2, 5, 3], [2, 0, 3, 5]])
Output4