当前位置:网站首页>Li Kou daily question - Day 32 -1232 Dotted line
Li Kou daily question - Day 32 -1232 Dotted line
2022-07-01 18:47:00 【Chongyou research Sen】
2022.7.1 Did you brush the questions today ?
subject :
Given an array coordinates , among coordinates[i] = [x, y] , [x, y] The abscissa is x、 Ordinate for y The point of . Please judge , Whether these points belong to the same line in the coordinate system .
analysis :
Here are some two-dimensional arrays , You need to judge whether these two-dimensional arrays are on a straight line , But one thing to pay attention to , If you're going to find out y=kx+b To judge , There will be cases where the denominator is negative when the slope is divided !
Ideas : Using the slope formula
(y1-y0)/(x1-x0)=(yi-y0)/(xi-x0) Prevention and elimination 0, Transformed into a form of multiplication (y1-y0)*(xi-x0)==(x1-x0)*(yi-y0)
analysis :
1. Violent solution
class Solution {
public:
bool checkStraightLine(vector<vector<int>>& coordinates) {
for (auto i = 2; i < coordinates.size(); i++)
{
if ((coordinates[1][1]-coordinates[0][1])*(coordinates[i][0]-coordinates[0][0])!=(coordinates[i][1]-coordinates[0][1])*(coordinates[1][0]-coordinates[0][0]))
{
return false;
}
}
return true;
}
};边栏推荐
- 1380. Lucky number in matrix / 1672 Total assets of the richest customers
- How does factor analysis calculate weights?
- Roll out! Enlightenment!
- 12种数据量纲化处理方式
- Implement a Prometheus exporter
- 力扣每日一题-第32天-1232. 缀点成线
- How to find the optimal learning rate
- Lumiprobe bifunctional crosslinker sulfo cyanine 5 bis NHS ester
- [Chongqing Guangdong education] basic psychology reference materials of Tianjin Normal University
- D. Yet Another Minimization Problem
猜你喜欢

MySQL connection tools

Lumiprobe biomolecular quantification - qudye Protein Quantification Kit

解决方案:可以ping别人,但是别人不能ping我

Lumiprobe 生物分子定量丨QuDye 蛋白定量试剂盒

创建您自己的NFT集合并发布一个Web3应用程序来展示它们(介绍)

斯坦福、Salesforce|MaskViT:蒙面视觉预训练用于视频预测

Leetcode-160相交链表

用GSConv+Slim Neck改进Yolov5,将性能提升到极致!
![[source code analysis] model parallel distributed training Megatron (5) -- pipestream flush](/img/c0/25c1b96cc56fbd0231d32214d66718.jpg)
[source code analysis] model parallel distributed training Megatron (5) -- pipestream flush

Vidéos courtes recommandées chaque semaine: méfiez - vous de la confusion entre « phénomène » et « problème »
随机推荐
Five degrees easy chain enterprise app is newly upgraded
Mise en place d'une plate - forme générale de surveillance et d'alarme, quelles sont les conceptions nécessaires dans l'architecture?
Blue Bridge Cup real problem: word analysis
Why do independent website sellers start to do social media marketing? The original customer conversion rate can be improved so much!
12种数据量纲化处理方式
《Go题库·16》读写锁底层是怎么实现的
如何在自有APP内实现小程序实现连麦直播
R语言ggplot2可视化:可视化折线图、使用labs函数为折线图添加自定义的Y轴标签信息(customize y axis label)
Memo - about C # generating barcode for goods
GAMES202作业0-环境搭建过程&解决遇到的问题
Is it safe to open a securities account? Is there any danger
Classpath classpath
Go Technology Daily (2022-02-14) - go language slice interview real questions 8 consecutive questions
Halcon image calibration enables subsequent image processing to become the same as the template image
Relational database management system of easyclick
GameFramework食用指南
Sanfeng cloud 0215 I often use
[source code analysis] NVIDIA hugectr, GPU version parameter server - (1)
Livedata postvalue will "lose" data
宏观视角看抖音全生态