当前位置:网站首页>力扣 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
边栏推荐
- 干货分享|DevExpress v22.1原版帮助文档下载集合
- [confluence] JVM memory adjustment
- sql 常用优化
- 吞吐量Throughout
- 关于cv2.dnn.readNetFromONNX(path)就报ERROR during processing node with 3 inputs and 1 outputs的解决过程【独家发布】
- Is PMP beneficial to work? How to choose a reliable platform to make it easier to prepare for the exam!!!
- Matplotlib drawing 3D graphics
- Cloud 组件发展升级
- 爬虫实战(七):爬王者英雄图片
- 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
猜你喜欢
剑指 Offer II 013. 二维子矩阵的和
最多可以参加的会议数目[贪心 + 优先队列]
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!!!
模拟实现string类
Navicat连接2002 - Can‘t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock‘解决
Leetcode force buckle (Sword finger offer 36-39) 36 Binary search tree and bidirectional linked list 37 Serialize binary tree 38 Arrangement of strings 39 Numbers that appear more than half of the tim
谷歌seo外链Backlinks研究工具推荐
2022如何评估与选择低代码开发平台?
Ways to improve the utilization of openeuler resources 01: Introduction
Dynamic addition of El upload upload component; El upload dynamically uploads files; El upload distinguishes which component uploads the file.
随机推荐
开源重器!九章云极DataCanvas公司YLearn因果学习开源项目即将发布!
LeetCode力扣(剑指offer 36-39)36. 二叉搜索树与双向链表37. 序列化二叉树38. 字符串的排列39. 数组中出现次数超过一半的数字
【剑指offer】剑指 Offer II 012. 左右两边子数组的和相等
PMP对工作有益吗?怎么选择靠谱平台让备考更省心省力!!!
ASP.NET幼儿园连锁管理系统源码
MSE API学习
openEuler 资源利用率提升之道 01:概论
R language ggplot2 visualization: use the ggdensity function of ggpubr package to visualize the packet density graph, and use stat_ overlay_ normal_ The density function superimposes the positive dist
[Verilog advanced challenge of Niuke network question brushing series] ~ multi bit MUX synchronizer
谷歌seo外链Backlinks研究工具推荐
what‘s the meaning of inference
what‘s the meaning of inference
ant desgin 多选
【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
831. KMP字符串
位运算介绍
强化学习-学习笔记8 | Q-learning
【STL】vector
Implement secondary index with Gaussian redis