题目要求

You have a list of points in the plane. Return the area of the largest triangle that can be formed by any 3 of the points.

题目分析及思路

给定一个平面上的一组点,要求得到由这些点中任意三个所能组成最大面积的三角形。可以对这一组点进行三三组合,然后利用已知三点求三角形面积的公式得到每一组点所对应的三角形面积,最后取其中的最大值即为所求。

python代码

class Solution:

def largestTriangleArea(self, points: List[List[int]]) -> float:

def area(p, q, r):

return .5 * abs(p[0]*q[1] - p[1]*q[0] + q[0]*r[1] - q[1]*r[0] + r[0]*p[1] - r[1]*p[0])

return max(area(*tri_points) for tri_points in itertools.combinations(points, 3))

LeetCode 812 Largest Triangle Area 解题报告的更多相关文章

  1. 【LeetCode】812. Largest Triangle Area 解题报告(Python)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 三重循环 组合函数 日期 题目地址:https:// ...

  2. 【Leetcode_easy】812. Largest Triangle Area

    problem 812. Largest Triangle Area solution: class Solution { public: double largestTriangleArea(vec ...

  3. 【LeetCode】223. Rectangle Area 解题报告(Python)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址: https://leetcode.com/problems/rectangl ...

  4. LeetCode: Pascal's Triangle II 解题报告

    Pascal's Triangle II Total Accepted: 19384 Total Submissions: 63446 My Submissions Question Solution ...

  5. 812. Largest Triangle Area

    static int wing=[]() { std::ios::sync_with_stdio(false); cin.tie(NULL); ; }(); class Solution { publ ...

  6. 【LeetCode】764. Largest Plus Sign 解题报告(Python)

    [LeetCode]764. Largest Plus Sign 解题报告(Python) 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn ...

  7. 【LeetCode】Pascal's Triangle II 解题报告

    [LeetCode]Pascal's Triangle II 解题报告 标签(空格分隔): LeetCode 题目地址:https://leetcode.com/problems/pascals-tr ...

  8. LeetCode 2 Add Two Sum 解题报告

    LeetCode 2 Add Two Sum 解题报告 LeetCode第二题 Add Two Sum 首先我们看题目要求: You are given two linked lists repres ...

  9. 【LeetCode】376. Wiggle Subsequence 解题报告(Python)

    [LeetCode]376. Wiggle Subsequence 解题报告(Python) 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.c ...

随机推荐

  1. Mycat源码中的单例模式

    在MyCat的源码中,很多对象都使用到了单例模式. 首先是MycatServer类,该实例必须全局唯一,所以这里涉及到JAVA的单实例模式,就是一个类只有唯一一个实例对象存在.先来看看mycat源码是 ...

  2. Thinkphp的S缓存用法!

    /节点列表 public function node(){ if(!$node = S('node_list')){ $field = array('id', 'name', 'title', 'pi ...

  3. <我的股票交易知识汇总与个人感悟_v1.0 (By geman)>

    书在这里 一个完整的股票交易包括选股.买股.持股.卖股四个阶段. 右侧交易,顶是跌出来的,底是涨出来的 一定要敢于止损,设好止损位,严格执行,即使踏空也无怨无悔:资金安全第一位 坚持只买处于上升通道的 ...

  4. JavaScript Scroll家族以及封装

    JavaScript Scroll家族以及封装 scrollTop & scrollLeft 别卷去的值,就是当滑动滚轮浏览网页的时候,网页隐藏在屏幕上方或左侧的距离 获得scrollTop ...

  5. Why you should use async tasks in .NET 4.5 and Entity Framework 6

    Improve response times and handle more users with parallel processing Building a web application usi ...

  6. Java----------JMX规范

    作者:郭无心链接:https://www.zhihu.com/question/36688387/answer/68667704来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商业转载请注明 ...

  7. SpringBoot(三)整合Redis

    spring boot对常用的数据库支持外,对nosql 数据库也进行了封装自动化. redis介绍 Redis是目前业界使用最广泛的内存数据存储.相比memcached,Redis支持更丰富的数据结 ...

  8. MyISAM和InnoDB区别 及选择

    MySQL默认采用的是MyISAM. MyISAM不支持事务,而InnoDB支持.InnoDB的AUTOCOMMIT默认是打开的,即每条SQL语句会默认被封装成一个事务,自动提交,这样会影响速度,所以 ...

  9. Ubuntu上pip安装uwsgi失败的原因之一(未联网)

    ubuntu@ubuntu:~$ sudo pip install uwsgi 报错:The directory '/home/ubuntu/.cache/pip/http' or its paren ...

  10. 读《Spring源码深度解析》途中问题1

    step 1:检查自己的eclipse版本:在help->About Eclipse中查看: step 2:进入 https://github.com/groovy/groovy-eclipse ...