当前位置:网站首页>力扣 1232.缀点成线
力扣 1232.缀点成线
2022-07-07 17:53:00 【Tomorrowave】
1232.缀点成线
给定一个数组 coordinates ,其中 coordinates[i] = [x, y] , [x, y] 表示横坐标为 x、纵坐标为 y 的点。请你来判断,这些点是否在该坐标系中属于同一条直线上。
示例 1:
输入:coordinates = [[1,2],[2,3],[3,4],[4,5],[5,6],[6,7]]
输出:true
思路
利用斜率的乘积来做
代码部分
class Solution:
def checkStraightLine(self, coordinates: List[List[int]]) -> bool:
a=coordinates[1][0]-coordinates[0][0]
b=coordinates[1][1]-coordinates[0][1]
for i in range(2,len(coordinates)):
c = coordinates[i][0] - coordinates[0][0]
d = coordinates[i][1] - coordinates[0][1]
if (a * d - b * c != 0):
return False
return True
边栏推荐
- Boot 和 Cloud 的版本选型
- Kirin Xin'an joins Ningxia commercial cipher Association
- Visual Studio 插件之CodeMaid自动整理代码
- How to buy bank financial products? Do you need a bank card?
- 我的创作纪念日
- Some arrangements about oneself
- “本真”是什么意思
- Flink并行度和Slot详解
- Make insurance more "safe"! Kirin Xin'an one cloud multi-core cloud desktop won the bid of China Life Insurance, helping the innovation and development of financial and insurance information technolog
- Redis——基本使用(key、String、List、Set 、Zset 、Hash、Geo、Bitmap、Hyperloglog、事务 )
猜你喜欢

Detailed explanation of Flink parallelism and slot

Make insurance more "safe"! Kirin Xin'an one cloud multi-core cloud desktop won the bid of China Life Insurance, helping the innovation and development of financial and insurance information technolog

Download from MySQL official website: mysql8 for Linux X Version (Graphic explanation)

Le PGR est - il utile au travail? Comment choisir une plate - forme fiable pour économiser le cœur et la main - d'œuvre lors de la préparation de l'examen!!!

【STL】vector

ASP.NET幼儿园连锁管理系统源码

Kirin Xin'an joins Ningxia commercial cipher Association

Dynamic addition of El upload upload component; El upload dynamically uploads files; El upload distinguishes which component uploads the file.

Kunpeng developer summit 2022 | Kirin Xin'an and Kunpeng jointly build a new ecosystem of computing industry

【RT-Thread env 工具安装】
随机推荐
J ü rgen schmidhub reviews the 25th anniversary of LSTM papers: long short term memory All computable metaverses. Hierarchical reinforcement learning (RL). Meta-RL. Abstractions in generative adversar
9 原子操作类之18罗汉增强
位运算介绍
openEuler 资源利用率提升之道 01:概论
Browse the purpose of point setting
银行理财产品怎么买?需要办银行卡吗?
干货分享|DevExpress v22.1原版帮助文档下载集合
国家网信办公布《数据出境安全评估办法》:累计向境外提供10万人信息需申报
【STL】vector
Automatic classification of defective photovoltaic module cells in electroluminescence images-論文閱讀筆記
Kirin Xin'an won the bid for the new generation dispatching project of State Grid!
Le PGR est - il utile au travail? Comment choisir une plate - forme fiable pour économiser le cœur et la main - d'œuvre lors de la préparation de l'examen!!!
AD域组策略管理
Visual Studio 插件之CodeMaid自动整理代码
Kubernetes——kubectl命令行工具用法详解
Boot 和 Cloud 的版本选型
L1-027 rental (Lua)
Cloud 组件发展升级
Install mysql8 for Linux X ultra detailed graphic tutorial
R语言使用ggplot2函数可视化需要构建泊松回归模型的计数目标变量的直方图分布并分析构建泊松回归模型的可行性