当前位置:网站首页>力扣 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
边栏推荐
- “本真”是什么意思
- torch. nn. functional. Pad (input, pad, mode= 'constant', value=none) record
- Jürgen Schmidhuber回顾LSTM论文等发表25周年:Long Short-Term Memory. All computable metaverses. Hierarchical reinforcement learning (RL). Meta-RL. Abstractions in generative adversarial RL. Soccer learn
- tp6 实现佣金排行榜
- 编译器优化那些事儿(4):归纳变量
- Simulate the implementation of string class
- 剑指 Offer II 013. 二维子矩阵的和
- 线性基
- [confluence] JVM memory adjustment
- 银行理财产品怎么买?需要办银行卡吗?
猜你喜欢

【STL】vector

8 CAS

微信公众号OAuth2.0授权登录并显示用户信息

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

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!!!

论文解读(ValidUtil)《Rethinking the Setting of Semi-supervised Learning on Graphs》

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

9 atomic operation class 18 Rohan enhancement

ASP. Net kindergarten chain management system source code

LeetCode_7_5
随机推荐
The strength index of specialized and new software development enterprises was released, and Kirin Xin'an was honored on the list
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!!!
Compiler optimization (4): inductive variables
openEuler 有奖捉虫活动,来参与一下?
2022年投资哪个理财产品收益高?
Sword finger offer II 013 Sum of two-dimensional submatrix
LeetCode_ 7_ five
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
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
Ways to improve the utilization of openeuler resources 01: Introduction
how to prove compiler‘s correctness
Kubernetes——kubectl命令行工具用法详解
Unable to link the remote redis server (solution 100%
开源OA开发平台:合同管理使用手册
R语言ggplot2可视化:使用ggpubr包的ggstripchart函数可视化分组点状条带图(dot strip plot)、设置position参数配置不同分组数据点的分离程度
what‘s the meaning of inference
线性基
Introduction to bit operation
关于自身的一些安排
R language dplyr package select function, group_ The by function, filter function and do function obtain the third largest value of a specific numerical data column in a specified level in a specified