# Largest Triangle Area Problem & Solution

Given an array of points on the X-Y plane points where `points[i] = [xi, yi]`, return the area of the largest triangle that can be formed by any three different points. Answers within `10^-5` of the actual answer will be accepted.

## C++ Solution

``````#pragma GCC optimize("Ofast")
#pragma GCC optimization("fast-math")
#pragma GCC optimization("unroll-loops")
#pragma GCC target("avx,avx2,fma")

static const int _=[](){std::ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);return 0;}();

class Solution {
public:
double largestTriangleArea(vector<vector<int>>& points) {
double largest = 0;

for (int i = 0; i < points.size() - 2; ++i) {
for (int j = i + 1; j < points.size() - 1; ++j) {
for (int k = j + 1; k < points.size(); ++k) {
double area = abs(0.5 * (points[i] * (points[j] - points[k]) + points[j] * (points[k] - points[i]) + points[k] * (points[i] - points[j])));

largest = max(largest, area);
}
}
}

return largest;
}
};
``````

## Start Here

Many paths, there are. Follow yours, you must.