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

Matplotlib drawing 3D graphics

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

# 欢迎使用Markdown编辑器

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

Install mysql8 for Linux X ultra detailed graphic tutorial

【STL】vector

8 CAS

位运算介绍

Kirin Xin'an won the bid for the new generation dispatching project of State Grid!

Navicat连接2002 - Can‘t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock‘解决
随机推荐
R语言dplyr包mutate_at函数和min_rank函数计算dataframe中指定数据列的排序序号值、名次值、将最大值的rank值赋值为1
Dynamic addition of El upload upload component; El upload dynamically uploads files; El upload distinguishes which component uploads the file.
[RT thread env tool installation]
谷歌seo外链Backlinks研究工具推荐
Kubernetes——kubectl命令行工具用法详解
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
Introduction to bit operation
UCloud是基础云计算服务提供商
位运算介绍
Matplotlib drawing 3D graphics
Make this crmeb single merchant wechat mall system popular, so easy to use!
Solve the problem of remote rviz error reporting
R语言fpc包的dbscan函数对数据进行密度聚类分析、查看所有样本的聚类标签、table函数计算聚类簇标签与实际标签构成的二维列联表
【剑指offer】剑指 Offer II 012. 左右两边子数组的和相等
openEuler 资源利用率提升之道 01:概论
Automatic classification of defective photovoltaic module cells in electroluminescence images-论文阅读笔记
“本真”是什么意思
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
Ucloud is a basic cloud computing service provider
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