Practice Maximum Square Area by Removing Fences From a Field
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Maximum Square Area by Removing Fences From a Field
Problem Statement
The field extends from (1,1) to (m,n). hFences gives horizontal fence coordinates and vFences vertical ones. Remove any interior fences to create the largest square region; the four outer boundary fences cannot be removed. Return its area modulo 10^9 + 7, or -1 if no square can be formed.
Source: Maximum Square Area by Removing Fences From a Field on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
m = 4, n = 3, hFences = [2,3], vFences = [2]
4
# Example 2
m = 6, n = 7, hFences = [2], vFences = [4]
-1
Constraints
Related LeetCode Problems
Practice more problems similar to Maximum Square Area by Removing Fences From a Field.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.