Practice Find Maximum Area of a Triangle
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Find Maximum Area of a Triangle
Problem Statement
You are given a 2D array coords of size n x 2, representing the coordinates of n points in an infinite Cartesian plane. Find twice the maximum area of a triangle with its corners at any three elements from coords, such that at least one side of this triangle is parallel to the x-axis or y-axis. Formally, if the maximum area of such a triangle is A, return 2 * A. If no such triangle exists, return -1. Note that a triangle cannot have zero area.
Source: Find Maximum Area of a Triangle on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
coords = [[1,1],[1,2],[3,2],[3,3]]
2
# Example 2
coords = [[1,1],[2,2],[3,3]]
-1
Constraints
Related LeetCode Problems
Practice more problems similar to Find Maximum Area of a Triangle.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.