LeetCode 812 Largest Triangle Area 解题报告
题目要求
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 解题报告的更多相关文章
- 【LeetCode】812. Largest Triangle Area 解题报告(Python)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 三重循环 组合函数 日期 题目地址:https:// ...
- 【Leetcode_easy】812. Largest Triangle Area
problem 812. Largest Triangle Area solution: class Solution { public: double largestTriangleArea(vec ...
- 【LeetCode】223. Rectangle Area 解题报告(Python)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址: https://leetcode.com/problems/rectangl ...
- LeetCode: Pascal's Triangle II 解题报告
Pascal's Triangle II Total Accepted: 19384 Total Submissions: 63446 My Submissions Question Solution ...
- 812. Largest Triangle Area
static int wing=[]() { std::ios::sync_with_stdio(false); cin.tie(NULL); ; }(); class Solution { publ ...
- 【LeetCode】764. Largest Plus Sign 解题报告(Python)
[LeetCode]764. Largest Plus Sign 解题报告(Python) 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn ...
- 【LeetCode】Pascal's Triangle II 解题报告
[LeetCode]Pascal's Triangle II 解题报告 标签(空格分隔): LeetCode 题目地址:https://leetcode.com/problems/pascals-tr ...
- LeetCode 2 Add Two Sum 解题报告
LeetCode 2 Add Two Sum 解题报告 LeetCode第二题 Add Two Sum 首先我们看题目要求: You are given two linked lists repres ...
- 【LeetCode】376. Wiggle Subsequence 解题报告(Python)
[LeetCode]376. Wiggle Subsequence 解题报告(Python) 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.c ...
随机推荐
- Node入门教程(9)第七章:NodeJs的文件处理
Node的文件处理涉及到前面说的ptah模块,以及fs文件系统.stream流处理.Buffer缓冲器等模块.内容可能比较多,相关内容请以官网文档为主,此处主要以案例讲解为主,分享给大家一些常用的经典 ...
- 《FPGA全程进阶---实战演练》第五章 基于74HC595的LED操作
1基础理论部分 1.1分频 分频,是的,这个概念也很重要.分频是指将一单一频率信号的频率降低为原来的1/N,就叫N分频.实现分频的电路或装置称为“分频器”,如把33MHZ的信号2分频得到16.5MHZ ...
- 【转】WPF自定义控件与样式(3)-TextBox & RichTextBox & PasswordBox样式、水印、Label标签、功能扩展
一.前言.预览 申明:WPF自定义控件与样式是一个系列文章,前后是有些关联的,但大多是按照由简到繁的顺序逐步发布的等. 本文主要是对文本输入控件进行样式开发,及相关扩展功能开发,主要内容包括: 基本文 ...
- Go指南练习_切片
源地址 https://tour.go-zh.org/moretypes/18 一.练习题描述 实现 Pic.它应当返回一个长度为 dy 的切片,其中每个元素是一个长度为 dx,元素类型为 uint8 ...
- Python终端自动补全
在-目录下添加一个文件,名字为.pythonstartup.py #!/usr/bin/python # -*- coding: UTF-8 -*- import readline, rlcomple ...
- golang net/http 包
https://studygolang.com/articles/9467 https://www.jianshu.com/p/be3d9cdc680b 客户端: 用来发送请求, 并处理返回结果. 涉 ...
- 【hadoop】 hdfs shell 命令交互
1.put 本地文件上传至hdfs中 2. cat 查看内容 3. 删除文件,文件夹 4. ls 5. copyFromLocal 复制本地文件到HDFS , copyToLocal hdfs 复制到 ...
- 《objective-c基础教程》学习笔记(三)—— 从结构体到面向对象
一听标题,感觉十分的抽象.面向对象就是(Object-Oriented Programming)的首字母缩写:OOP,是当今最主流的编程方法. 那么,面向对象编程具体有什么好处呢.是如何来实现呢?通过 ...
- HTTPS与证书
HTTPS(Secure Hypertext Transfer Protocol)安全超文本传输协议它是一个安全通信通道,它基于HTTP开发,用于在客户计算机和服务器之间交换信息.它使用安全套接字层( ...
- Linux设备驱动剖析之IIC(四)
558行,又重试2次. 560行,调用s3c24xx_i2c_doxfer函数: static int s3c24xx_i2c_doxfer(struct s3c24xx_i2c *i2c, stru ...