题目链接:812. 最大三角形面积
遍历所有可能的组合,计算面积,找到最大的一个。
from itertools import combinations
from typing import List
class Solution:
def largestTriangleArea(self, points: List[List[int]]) -> float:
def area(x0, y0, x1, y1, x2, y2) -> float:
return abs((x2 - x1) * (y0 - y1) - (x0 - x1) * (y2 - y1)) / 2
return max(area(x0, y0, x1, y1, x2, y2) for (x0, y0), (x1, y1), (x2, y2) in combinations(points, 3))