Tap here to switch tabs
Problem
Submissions

Problem: Find Maximum Area of a Triangle

Try to solve the Find Maximum Area of a Triangle problem.

Statement

You are given a 2D2\text{D} integer array coords where coords[i] = [x_i, y_i] represents a point on a 2D2\text{D} plane.

Find the maximum value of 2×area2 \times \text{area} of a triangle with a positive area formed by any three distinct points in coords such that at least one of its sides is parallel to the x axis or the y axis.

Return this maximum value, or −1-1 if no such triangle can be formed.

Constraints:

  • 1≤1 \leq coords.length ≤105\leq 10^5

  • 1≤1 \leq coords[i][0], coords[i][1] ≤106\leq 10^6

  • All coords[i] are unique.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Find Maximum Area of a Triangle

Try to solve the Find Maximum Area of a Triangle problem.

Statement

You are given a 2D2\text{D} integer array coords where coords[i] = [x_i, y_i] represents a point on a 2D2\text{D} plane.

Find the maximum value of 2×area2 \times \text{area} of a triangle with a positive area formed by any three distinct points in coords such that at least one of its sides is parallel to the x axis or the y axis.

Return this maximum value, or −1-1 if no such triangle can be formed.

Constraints:

  • 1≤1 \leq coords.length ≤105\leq 10^5

  • 1≤1 \leq coords[i][0], coords[i][1] ≤106\leq 10^6

  • All coords[i] are unique.