当前位置:网站首页>力扣 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
边栏推荐
- mock.js从对象数组中任选数据返回一个数组
- 【Confluence】JVM内存调整
- torch.nn.functional.pad(input, pad, mode=‘constant‘, value=None)记录
- My creation anniversary
- 2022如何评估与选择低代码开发平台?
- 干货分享|DevExpress v22.1原版帮助文档下载集合
- Solve the problem of remote rviz error reporting
- 谷歌seo外链Backlinks研究工具推荐
- ASP.NET幼儿园连锁管理系统源码
- torch. nn. functional. Pad (input, pad, mode= 'constant', value=none) record
猜你喜欢
九章云极DataCanvas公司摘获「第五届数字金融创新大赛」最高荣誉!
Kirin Xin'an cloud platform is newly upgraded!
Dynamic addition of El upload upload component; El upload dynamically uploads files; El upload distinguishes which component uploads the file.
Automatic classification of defective photovoltaic module cells in electroluminescence images-論文閱讀筆記
开源OA开发平台:合同管理使用手册
ASP.NET幼儿园连锁管理系统源码
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
小试牛刀之NunJucks模板引擎
Classification automatique des cellules de modules photovoltaïques par défaut dans les images de lecture électronique - notes de lecture de thèse
Compiler optimization (4): inductive variables
随机推荐
【剑指offer】剑指 Offer II 012. 左右两边子数组的和相等
Openeuler prize catching activities, to participate in?
tp6 实现佣金排行榜
现在股票开户可以直接在网上开吗?安全吗。
Redis——基本使用(key、String、List、Set 、Zset 、Hash、Geo、Bitmap、Hyperloglog、事务 )
openEuler 有奖捉虫活动,来参与一下?
我的创作纪念日
时间工具类
R language ggplot2 visualization: use the ggstripchart function of ggpubr package to visualize the dot strip plot, set the position parameter, and configure the separation degree of different grouped
Kirin Xin'an with heterogeneous integration cloud financial information and innovation solutions appeared at the 15th Hunan Financial Technology Exchange Conference
Unable to link the remote redis server (solution 100%
The strength index of specialized and new software development enterprises was released, and Kirin Xin'an was honored on the list
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
841. 字符串哈希
一锅乱炖,npm、yarn cnpm常用命令合集
让这个 CRMEB 单商户微信商城系统火起来,太好用了!
Boot 和 Cloud 的版本选型
模拟实现string类
Automatic classification of defective photovoltaic module cells in electroluminescence images-論文閱讀筆記
开源OA开发平台:合同管理使用手册