当前位置:网站首页>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;
}
};边栏推荐
- 用GSConv+Slim Neck改进Yolov5,将性能提升到极致!
- The ultimate version of the 13th simulation of the single chip microcomputer provincial competition of the Blue Bridge Cup
- Image acquisition and playback of coaxpress high speed camera based on pxie interface
- Salesmartly has some tricks for Facebook chat!
- OpenAI|视频预训练 (VPT):基于观看未标记的在线视频的行动学习
- Mysql database of easyclick
- Blue Bridge Cup real problem: word analysis
- Database - MySQL advanced SQL statement (I)
- Go Technology Daily (2022-02-14) - go language slice interview real questions 8 consecutive questions
- R语言使用dplyr包的transmute函数计算dataframe数据中的指定数据列的移动窗口均值、使用ggplot2包可视化移动均值与原始数据的折线图
猜你喜欢

Lumiprobe biomolecular quantification - qudye Protein Quantification Kit

12 data dimensioning processing methods

宏观视角看抖音全生态

Xia CaoJun ffmpeg 4.3 audio and video foundation to engineering application

Blue Bridge Cup real topic: the shortest circuit

Cloud computing - make learning easier

Leetcode-141环形链表

Data query language (DQL)

Five degrees easy chain enterprise app is newly upgraded

Mysql database design
随机推荐
每周推荐短视频:警惕“现象”与“问题”相互混淆
AI 训练速度突破摩尔定律;宋舒然团队获得RSS 2022最佳论文奖
Mysql database design
实现一个Prometheus exporter
What if the reliability coefficient is low? How to calculate the reliability coefficient?
创建您自己的NFT集合并发布一个Web3应用程序来展示它们(介绍)
The 13th simulation problem of the single chip microcomputer provincial competition of the Blue Bridge Cup
Operation of cmake under win
Leetcode-141环形链表
C language learning notes: type definition typedef and declaration external CSDN creation punch in
Why do independent website sellers start to do social media marketing? The original customer conversion rate can be improved so much!
R语言epiDisplay包ordinal.or.display函数获取有序logistic回归模型的汇总统计信息(变量对应的优势比及其置信区间、以及假设检验的p值)、write.csv函数保存csv
Depth first search - DFS (burst search)
Memo - about C # generating barcode for goods
Sum of three numbers
3、《创建您自己的NFT集合并发布一个Web3应用程序来展示它们》在本地铸造 NFT
Localization through custom services in the shuttle application
关于企业中台规划和 IT 架构微服务转型
Navicat Premium 15 永久破解和2021版本最新IDEA破解(亲测有效)
R语言使用dplyr包的transmute函数计算dataframe数据中的指定数据列的移动窗口均值、使用ggplot2包可视化移动均值与原始数据的折线图