Google L3 Onsite

Difficulty: EASYCategory: InterviewExperienceFrequency: 1Asked On 2025-05-03Added By Anonymous
Source: Link
🧭 Experience: unknown
✅ Outcome: unknown
💰 Compensation: unknown
📍 Location: unknown
🏢 Company: Google
🎓 Education: unknown
🎁 Benefits: unknown
📅 Offer Date: unknown

Hey everyone 👋,

I came across a really interesting and challenging geometry-based problem during my Google onsite round.

You're given a list of distinct 2D points on a Cartesian plane. Your task is to find the area of the largest rectangle that can be formed by selecting any four points from the list such that those four points form the corners of a valid rectangle.

🔹 Important Constraints:

The rectangle does not need to be axis-aligned.

The rectangle can lie in any orientation (e.g., rotated at 45 degrees).

All four corners of the rectangle must be present in the input point list.

Your goal is to compute the maximum possible area of any such rectangle.

points = [
[-5, -5], [-5, 0], [0, -5], [0, 0],
[-3, 2], [-2, 3], [1, 2], [0, 1],
[-4, -1], [1, -6], [1, -1], [-4, -6],
[2, 2], [3, 3], [4, 4],
[-2, -2], [-1, -1], [0, 0], [1, 1],
[5, 5], [-5, 5], [5, -5], [-5, -5]
]

The largest rectangle is formed by these 4 points:

[5, 5], [-5, 5], [5, -5], [-5, -5]

Max Area = 100
Comments