当前位置:网站首页>力扣 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
边栏推荐
猜你喜欢

# 欢迎使用Markdown编辑器

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

项目经理『面试八问』,看了等于会了

PMP practice once a day | don't get lost in the exam -7.7

Kirin Xin'an joins Ningxia commercial cipher Association
Make this crmeb single merchant wechat mall system popular, so easy to use!

PMP对工作有益吗?怎么选择靠谱平台让备考更省心省力!!!

mock. JS returns an array from the optional data in the object array

【STL】vector

8 CAS
随机推荐
ASP. Net kindergarten chain management system source code
Some arrangements about oneself
吞吐量Throughout
MSE API学习
关于ssh登录时卡顿30s左右的问题调试处理
Kubernetes——kubectl命令行工具用法详解
线性基
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
8 CAS
PMP对工作有益吗?怎么选择靠谱平台让备考更省心省力!!!
RESTAPI 版本控制策略【eolink 翻译】
mock. JS returns an array from the optional data in the object array
让这个 CRMEB 单商户微信商城系统火起来,太好用了!
【RT-Thread env 工具安装】
Solve the problem of remote rviz error reporting
Make this crmeb single merchant wechat mall system popular, so easy to use!
Automatic classification of defective photovoltaic module cells in electroluminescence images-論文閱讀筆記
My creation anniversary
Open source heavy ware! Chapter 9 the open source project of ylarn causal learning of Yunji datacanvas company will be released soon!
Dynamic addition of El upload upload component; El upload dynamically uploads files; El upload distinguishes which component uploads the file.