当前位置:网站首页>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;
}
};边栏推荐
- Livedata postvalue will "lose" data
- D. Yet Another Minimization Problem
- Sum of three numbers
- Introduction to easyclick database
- Write an open source, convenient and fast database document query and generation tool with WPF
- R language uses follow up of epidisplay package Plot function visualizes the longitudinal follow-up map of multiple ID (case) monitoring indicators, and uses n.of The lines parameter specifies the num
- 如何在自有APP内实现小程序实现连麦直播
- Is the fund of futures account safe? How to open an account?
- AI 训练速度突破摩尔定律;宋舒然团队获得RSS 2022最佳论文奖
- 540. Single element in ordered array / 1684 Count the number of consistent strings
猜你喜欢

GAMES202作业0-环境搭建过程&解决遇到的问题

6款红黄黑榜摄像头评测:谁最安全?谁画质好?从此让你不再踩雷

Lumiprobe非荧光炔烃丨EU(5-乙炔基尿苷)

Operation of cmake under win

Must see, time series analysis

用GSConv+Slim Neck改进Yolov5,将性能提升到极致!

Relational database management system of easyclick

2、《创建您自己的NFT集合并发布一个Web3应用程序来展示它们》启动并运行您的本地环境

12种数据量纲化处理方式

A database editing gadget that can edit SQLite database. SQLite database replaces fields. SQL replaces all values of a field in the database
随机推荐
关于企业中台规划和 IT 架构微服务转型
Facebook聊单,SaleSmartly有妙招!
Implementation of converting PCM file to WAV
搭建一个通用监控告警平台,架构上需要有哪些设计
How to find the optimal learning rate
Vue uses keep alive to cache page optimization projects
What designs are needed in the architecture to build a general monitoring and alarm platform
Leetcode-128 最长连续序列
每周推薦短視頻:警惕“現象”與“問題”相互混淆
R language uses follow up of epidisplay package Plot function visualizes the longitudinal follow-up map of multiple ID (case) monitoring indicators, and uses n.of The lines parameter specifies the num
Memo - about C # generating barcode
The ultimate version of the 13th simulation of the single chip microcomputer provincial competition of the Blue Bridge Cup
Privacy sandbox is finally coming
Calculation of intersection of two line segments
Basic concepts of binary tree
The R language uses the tablestack function of epidisplay package to make statistical summary tables (descriptive statistics based on the grouping of target variables, hypothesis testing, etc.). If th
Leetcode203 移除链表元素
Leetcode-83 删除排序链表中重复的元素
Lumiprobe 生物分子定量丨QuDye 蛋白定量试剂盒
搭建一個通用監控告警平臺,架構上需要有哪些設計