当前位置:网站首页>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;
}
};边栏推荐
- Reading notes series "modern methods of C language programming" -- Chapter 2
- Salesmartly has some tricks for Facebook chat!
- 斯坦福、Salesforce|MaskViT:蒙面视觉预训练用于视频预测
- Leetcode-141环形链表
- 主成分之综合竞争力案例分析
- Static timing analysis (STA) in ic/fpga design
- 如何在自有APP内实现小程序实现连麦直播
- [Chongqing Guangdong education] basic psychology reference materials of Tianjin Normal University
- Lumiprobe 双功能交联剂丨Sulfo-Cyanine5 双-NHS 酯
- R语言使用epiDisplay包的tableStack函数制作统计汇总表格(基于目标变量分组的描述性统计、假设检验等)、不设置by参数则计算数据框指定数据列范围的基础描述性统计信息
猜你喜欢

PCL learning materials

Search 2D matrix 2

Find all missing numbers in the array

A database editing gadget that can edit SQLite database. SQLite database replaces fields. SQL replaces all values of a field in the database

About enterprise middle office planning and it architecture microservice transformation

实现一个Prometheus exporter
![[today in history] February 15: Pascal's father was born; YouTube was founded; Kotlin language comes out](/img/f3/20b73f3545cdd17b9fbc52bf493ab4.jpg)
[today in history] February 15: Pascal's father was born; YouTube was founded; Kotlin language comes out

Basic knowledge and commands of disk

必看,时间序列分析

Database - MySQL advanced SQL statement (I)
随机推荐
Case study on comprehensive competitiveness of principal components
PCL learning materials
用GSConv+Slim Neck改进Yolov5,将性能提升到极致!
Bug of QQ browser article comment: the commentator is wrong
A database editing gadget that can edit SQLite database. SQLite database replaces fields. SQL replaces all values of a field in the database
Salesmartly has some tricks for Facebook chat!
Search 2D matrix 2
因子分析怎么计算权重?
字节跳动数据平台技术揭秘:基于 ClickHouse 的复杂查询实现与优化
为什么独立站卖家都开始做社交媒体营销?原来客户转化率能提高这么多!
How to find customers for investment attraction in industrial parks
Opencv map reading test -- error resolution
12 data dimensioning processing methods
540. Single element in ordered array
Rust language - cargo, crates io
The 13th simulation problem of the single chip microcomputer provincial competition of the Blue Bridge Cup
Memo - about C # generating barcode for goods
GAMES202作业0-环境搭建过程&解决遇到的问题
R语言caTools包进行数据划分、scale函数进行数据缩放、class包的knn函数构建K近邻分类器、table函数计算混淆矩阵
[image denoising] matlab code for removing salt and pepper noise based on fast and effective multistage selective convolution filter