当前位置:网站首页>力扣 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
边栏推荐
- Kirin Xin'an with heterogeneous integration cloud financial information and innovation solutions appeared at the 15th Hunan Financial Technology Exchange Conference
- 微信公众号OAuth2.0授权登录并显示用户信息
- equals 方法
- Classification automatique des cellules de modules photovoltaïques par défaut dans les images de lecture électronique - notes de lecture de thèse
- 干货分享|DevExpress v22.1原版帮助文档下载集合
- R language ggplot2 visualization: use the ggviolin function of ggpubr package to visualize the violin diagram, set the palette parameter to customize the filling color of violin diagrams at different
- R language dplyr package mutate_ At function and min_ The rank function calculates the sorting sequence number value and ranking value of the specified data column in the dataframe, and assigns the ra
- 关于自身的一些安排
- LeetCode_7_5
- how to prove compiler‘s correctness
猜你喜欢

【RT-Thread env 工具安装】

Automatic classification of defective photovoltaic module cells in electroluminescence images-论文阅读笔记

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

LeetCode_ 7_ five

Netease Yunxin participated in the preparation of the standard "real time audio and video service (RTC) basic capability requirements and evaluation methods" issued by the Chinese Academy of Communica
![[RT thread env tool installation]](/img/bc/9b39651d40a240f0893200793f67e9.png)
[RT thread env tool installation]

九章云极DataCanvas公司摘获「第五届数字金融创新大赛」最高荣誉!

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

openEuler 有奖捉虫活动,来参与一下?

Empowering smart power construction | Kirin Xin'an high availability cluster management system to ensure the continuity of users' key businesses
随机推荐
how to prove compiler‘s correctness
国家网信办公布《数据出境安全评估办法》:累计向境外提供10万人信息需申报
841. String hash
How to open an account for stock speculation? Excuse me, is it safe to open a stock account by mobile phone?
项目经理『面试八问』,看了等于会了
Dynamic addition of El upload upload component; El upload dynamically uploads files; El upload distinguishes which component uploads the file.
Browse the purpose of point setting
How to cooperate among multiple threads
一张图深入的理解FP/FN/Precision/Recall
Mysql, sqlserver Oracle database connection mode
R语言ggplot2可视化:使用ggpubr包的ggdensity函数可视化分组密度图、使用stat_overlay_normal_density函数为每个分组的密度图叠加正太分布曲线
ASP.NET幼儿园连锁管理系统源码
R language uses ggplot2 function to visualize the histogram distribution of counting target variables that need to build Poisson regression model, and analyzes the feasibility of building Poisson regr
ASP.NET体育馆综合会员管理系统源码,免费分享
2022年投资哪个理财产品收益高?
爬虫实战(七):爬王者英雄图片
最多可以参加的会议数目[贪心 + 优先队列]
Introduction to bit operation
多个线程之间如何协同
What does "true" mean