题目要求

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. 【Python】python3.6中实现同一行动态输出

    print同时需要设置flush=True来动态显示 print("\r[{0}] {1} <- {2}".format(username,time,jdTimeFomat) ...

  2. Error:java: invalid source release 无效的源发行版: 8

    原因:这是由于jdk的版本与项目的要求不一致造成的,如果是maven项目,首先查看一下pom.xml,以我的项目为例: 从其中可以看出要求的编译插件为1.8版本,而我本机上安装的jdk为1.7版本,因 ...

  3. MapReduce教程(二)MapReduce框架Partitioner分区<转>

    1 Partitioner分区 1.1 Partitioner分区描述 在进行MapReduce计算时,有时候需要把最终的输出数据分到不同的文件中,按照手机号码段划分的话,需要把同一手机号码段的数据放 ...

  4. 3D 特征点概述(1)

    很久没有更新相关内容了,很多朋友过来私信我,但由于时间问题,不能一一为大家解答,本人也不是无所不知的大神,还请各位谅解. 本文主要总结PCL中3D特征点的相关内容,该部分内容在PCL库中都是已经集成的 ...

  5. 使用echo $? 查看命令是否执行成功

    shell中的特殊变量:变量名含义$0shell或shell脚本的名字$*以一对双引号给出参数列表$@将各个参数分别加双引号返回$#参数的个数$_代表上一个命令的最后一个参数$$代表所在命令的PID$ ...

  6. Java知多少(14)数组

    如果希望保存一组有相同类型的数据,可以使用数组. 数组的定义和内存分配 Java 中定义数组的语法有两种: type arrayName[]; type[] arrayName; type 为Java ...

  7. Tip 18 – How to decide on a lifetime for your ObjectContext

    Alex D James 7 May 2009 3:44 PM One of the most common questions we get is how long should an Object ...

  8. 关于spring boot自动注入出现Consider defining a bean of type 'xxx' in your configuration问题解决方案

    搭建完spring boot的demo后自然要实现自动注入来体现spring ioc的便利了,但是我在实施过程中出现了这么一个问题,见下面,这里找到解决办法记录下来,供遇到同样的问题的同僚参考 Des ...

  9. Java 8 并发性基础

    https://www.ibm.com/developerworks/cn/java/j-jvmc2/index.html http://www.nurkiewicz.com/2013/05/java ...

  10. 如何修改DEDECMS文章标题长度

    方法一:      首先你要进入dedecms后台,系统——系统基本参数——其他选项——文档标题最大长度——在这修改为200或更大(其实200应该是足够了). 方法二:      进入phpmyadm ...