Tap here to switch tabs
Problem
Submissions

Problem: Maximum Square Area by Removing Fences From a Field

med
30 min
Try to solve the Maximum Square Area by Removing Fences From a Field problem.

Statement

There is a rectangular field with dimensions m $ imes$ n. The field has boundary horizontal fences at positions 11 and m, and boundary vertical fences at positions 11 and n.

Inside the field, additional horizontal fences are placed at positions specified by the array hFences, and additional vertical fences are placed at positions specified by the array vFences.

You can remove any number of horizontal or vertical fences, including zero. Return the maximum area of a square field that can be formed by the remaining fences, modulo 109+710^9 + 7. If no square field can be formed, return −1-1.

Constraints:

  • 3≤3 \leq m, n ≤109\leq 10^9

  • 1≤1 \leq hFences.length, vFences.length ≤600\leq 600

  • 1<1 < hFences[i] << m

  • 1<1 < vFences[i] << n

  • All elements in hFences and vFences are unique.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Maximum Square Area by Removing Fences From a Field

med
30 min
Try to solve the Maximum Square Area by Removing Fences From a Field problem.

Statement

There is a rectangular field with dimensions m $ imes$ n. The field has boundary horizontal fences at positions 11 and m, and boundary vertical fences at positions 11 and n.

Inside the field, additional horizontal fences are placed at positions specified by the array hFences, and additional vertical fences are placed at positions specified by the array vFences.

You can remove any number of horizontal or vertical fences, including zero. Return the maximum area of a square field that can be formed by the remaining fences, modulo 109+710^9 + 7. If no square field can be formed, return −1-1.

Constraints:

  • 3≤3 \leq m, n ≤109\leq 10^9

  • 1≤1 \leq hFences.length, vFences.length ≤600\leq 600

  • 1<1 < hFences[i] << m

  • 1<1 < vFences[i] << n

  • All elements in hFences and vFences are unique.