Skip to content

Practice Maximum Area Rectangle With Point Constraints II

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Hard#3382
LeetCode Problem

Maximum Area Rectangle With Point Constraints II

Problem Statement

The arrays xCoord and yCoord give points (xCoord[i], yCoord[i]). Choose four points forming the corners of an axis-aligned rectangle that has no other input point inside it or on its border. Return the maximum area of such a rectangle, or -1 if none exists.

Source: Maximum Area Rectangle With Point Constraints II on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
xCoord = [1,1,3,3], yCoord = [1,3,1,3]
Output
4

# Example 2

Input
xCoord = [1,1,3,3,2], yCoord = [1,3,1,3,2]
Output
-1

# Example 3

Input
xCoord = [1,1,3,3,1,3], yCoord = [1,3,1,3,2,2]
Output
2

Constraints

1 <= xCoord.length == yCoord.length <= 2 * 10^5
0 <= xCoord[i], yCoord[i] <= 8 * 10^7
All the given points are unique.

Related LeetCode Problems

Practice more problems similar to Maximum Area Rectangle With Point Constraints II.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.