FastPrepMaximum-Area Rectangle from Points
Problems/Maximum-Area Rectangle from Points

Maximum-Area Rectangle from Points

Google logoGoogle● HardFULLTIMEONSITE INTERVIEW
QuestionFunctionExamplesConstraints

Problem statement

Source note: The interview report asks for the largest rectangle obtainable from planar points, with arbitrary side orientation. The judged contract keeps that geometry task unchanged.

Given distinct integer-coordinate points in the plane, choose four of them that form a rectangle. The rectangle's sides do not need to be parallel to the axes.

Return the maximum possible rectangle area. Return 0 when no rectangle can be formed.

Function

maximumRectangleArea(points: int[][]) → long

Examples

Example 1

points = [[1,2],[2,1],[1,0],[0,1]]return = 2

The four points form a rotated square of area 2.

Example 2

points = [[0,0],[0,2],[3,0],[3,2],[1,1]]return = 6

The axis-aligned rectangle with width 3 and height 2 is largest.

Example 3

points = [[0,0],[1,1],[2,3]]return = 0

No four points are available to form a rectangle.

Constraints

  • 1 <= points.length <= 500.
  • Every point contains exactly two integers in [-40000, 40000].
  • All points are distinct.
  • The answer fits in a signed 64-bit integer.

More Google problems

  • Apartment Housemate PreferencesPHONE SCREEN · Seen Nov 2026
  • Price at Query TimestampsPHONE SCREEN · Seen Nov 2026
  • 0/1 Knapsack with Weight and Volume LimitsONSITE INTERVIEW · Seen Nov 2026
All Google interview questionsSee Google hiring insights
Saved
class Solution {
    public long maximumRectangleArea(int[][] points) {
        // Write your solution here.
    }
}
Checking account…