#2943

Maximize Area of Square Hole in Grid

specialist · 720 · lc medium +30 · 61.9% accepted · 637 likes · top 62%

Description

A grid has n + 2 horizontal bars and m + 2 vertical bars (indexed from 1) creating unit cells. You can remove any bars listed in hBars (horizontal) and vBars (vertical); boundary bars are fixed.

Return the largest square hole area you can create by removing some of the removable bars.

Code

1
2
3