题目要求

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. Oracle的NVL函数用法

    从两个表达式返回一个非 null 值. 语法 NVL(eExpression1, eExpression2) 参数eExpression1, eExpression2 如果 eExpression1 ...

  2. 在layui layer 弹出层中加载 layui table

    layui.use('table', function(){ var table = layui.table; layer.open({ type : 1, area : [ "600px& ...

  3. 模仿ReentrantLock类自定义锁

    简介 临近过年了,没什么需求,今天模仿ReentrantLock自定义写了一个自己锁,在这里记录一下,前提是对AQS原理有所了解,分享给大家 1.自定义锁MyLock package com.jack ...

  4. http://www.cnblogs.com/chenmeng0818/p/6370819.html

    http://www.cnblogs.com/chenmeng0818/p/6370819.html js中的正则表达式入门   什么是正则表达式呢? 正则表达式(regular expression ...

  5. irc

    https://www.irccloud.com/ webchat.freenode.net http://blog.csdn.net/wcc526/article/details/16993069 ...

  6. spring与quartz定时器

    参考: http://www.iteye.com/topic/399980 http://www.cnblogs.com/xrab/p/5850186.html

  7. [Converge] Batch Normalisation

    参考:https://www.zhihu.com/question/38102762 参考:CNN和RNN中如何引入BatchNorm 论文:Batch Normalization: Accelera ...

  8. linux下WEB服务器安装、配置VSFTP

    转载  http://www.oicto.com/centos-vsftp/?tdsourcetag=s_pcqq_aiomsg linux下WEB服务器安装.配置VSFTP 由 admin · 发布 ...

  9. 如何使用swfobject(中文版)

    1.SWFObject是什么? SWFObject 2提供两种优化flash播放器的嵌入方法:基于标记的方法和依赖于js的方法. SWFObject 2提供一个js的API,为嵌入SWF文件和获取Fl ...

  10. include_once与require_once的区别

    ①作用及用法  可以减少代码的重复 include(_once)("文件的路径")与require(_once)("文件的路径") ②理解 说白了,就是用包含进 ...