We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 36955f3 + 249d536 commit cb5302eCopy full SHA for cb5302e
812. Largest Triangle Area
@@ -0,0 +1,19 @@
1
+class Solution {
2
+public:
3
+ double largestTriangleArea(vector<vector<int>>& points) {
4
+ double max_area = 0.0;
5
+ int n = points.size();
6
+ for (int i = 0; i < n; ++i) {
7
+ for (int j = i + 1; j < n; ++j) {
8
+ for (int k = j + 1; k < n; ++k) {
9
+ int x1 = points[i][0], y1 = points[i][1];
10
+ int x2 = points[j][0], y2 = points[j][1];
11
+ int x3 = points[k][0], y3 = points[k][1];
12
+ double area = 0.5 * abs(x1*(y2 - y3) + x2*(y3 - y1) + x3*(y1 - y2));
13
+ max_area = max(max_area, area);
14
+ }
15
16
17
+ return max_area;
18
19
+};
0 commit comments