当前位置:网站首页>LeetCode:1037. 有效的回旋镖————简单
LeetCode:1037. 有效的回旋镖————简单
2022-06-10 19:43:00 【Kinght_123】

题目
1037. 有效的回旋镖
给定一个数组 points ,其中 points[i] = [xi, yi] 表示 X-Y 平面上的一个点,如果这些点构成一个 回旋镖 则返回 true 。
回旋镖 定义为一组三个点,这些点 各不相同 且 不在一条直线上 。
示例 1:
输入:points = [[1,1],[2,3],[3,2]]
输出:true
示例 2:
输入:points = [[1,1],[2,2],[3,3]]
输出:false
提示:
- points.length == 3
- points[i].length == 2
- 0 <= xi, yi <= 100
解题思路

- 数学。
- 如果三点共线,那么任意两个向量叉乘等于0.
Code
class Solution:
def isBoomerang(self, points: List[List[int]]) -> bool:
v1 = (points[1][0] - points[0][0], points[1][1] - points[0][1])
v2 = (points[2][0] - points[0][0], points[2][1] - points[0][1])
return v1[0] * v2[1] - v1[1] * v2[0] != 0
运行结果

边栏推荐
- torch.nn.Parameter的简单理解//未完待续,待我看懂这段
- 「Bug」问题分析 RuntimeError:which is output 0 of ReluBackward0
- Fs4521 constant voltage linear charging IC
- Networkx usage and nx Draw() related parameters
- 力扣1082,1084题解_sql查询类型的题目
- Knife4j configuration can use direct copy
- Deploying static websites using OSS and CDN on Alibaba cloud international
- 自定义日期组件,左右按钮控制向前或向后翻年、翻月、翻周、翻日
- knife4j配置使用直接拷贝即可
- Li Kou 10821084 solution_ Question of SQL query type
猜你喜欢

hidden danger? Limited meaning? Can't stop the real cooking Mini kitchenware hot 618

揭秘:春晚微信红包,是如何抗住 100 亿次请求的?

MySQL数据库基础

Microsoft Word 教程,如何在 Word 中更改页面方向、为页面添加边框?

KCon 2022 议题大众评选火热进行中!不要错过“心仪”的议题哦~

The new audio infinix machine appears in the Google product library, and Tecno CaMon 19 is pre installed with Android 13

玩艺术也得学数学?

How to realize face verification quickly and accurately?

Tutoriel Microsoft Word "5", comment changer les marges de page et créer une barre de nouvelles en word?

服务管理与通信,基础原理分析
随机推荐
2台电脑共享一套键盘鼠标
P5723 【深基4.例13】质数口袋
Does Seata still not support sqlserver?
「Bug」问题分析 RuntimeError:which is output 0 of ReluBackward0
table设置超出部分隐藏,鼠标移上去显示全部
Knowledge map / relationship visualization
Zabbix_ Principle Architecture - installation and deployment - Custom monitoring
RuntimeError: Attempting to deserialize object on CUDA device 1 but torch.cuda.device_count() is 1.
力扣1082,1084题解_sql查询类型的题目
The new audio infinix machine appears in the Google product library, and Tecno CaMon 19 is pre installed with Android 13
深度学习调参经验和工具
手写代码 bind
Rotated sorted array
Cloud native community boss blog
RuntimeError: Attempting to deserialize object on CUDA device 1 but torch. cuda. device_ count() is 1.
It took 2 years, 442 authors and 132 institutions! Google released the new benchmark big bench for language model evaluation. 204 tasks comprehensively evaluated the language model ability, with paper
为什么网页样式属性,有的需要加冒号“:”,有的不用?
堆叠条形图鼠标移入tooltip中提示过滤为0元素,实现自定义气泡
搭建一个BPMN建模的Web服务
[technical fragment] implementation of renaming and filtering duplicate name files with suffixes