Largest Triangle Area LeetCode solution in Python

1
from itertools import combinations
2

3

4
class Solution:
5
def largestTriangleArea(self, points: List[List[int]]) -> float:
6
maxA = 0
7
for p1, p2, p3 in combinations(points, 3):
8
x1, y1 = p1
9
x2, y2 = p2
10
x3, y3 = p3
11
A = (1 / 2) * abs(x1 * (y2 - y3) + x2 * (y3 - y1) + x3 * (y1 - y2))
12
if A > maxA:
13
maxA = A
14
return maxA

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0