当前位置:网站首页>Force deduction solution summary 1037- effective boomerang
Force deduction solution summary 1037- effective boomerang
2022-06-12 02:12:00 【Lost summer】
Directory links :
Force buckle programming problem - The solution sums up _ Share + Record -CSDN Blog
GitHub Synchronous question brushing items :
https://github.com/September26/java-algorithms
Original link : Power button
describe :
Given an array points , among points[i] = [xi, yi] Express X-Y A point on the plane , If these points form a Boomerang Then return to true .
Boomerang Defined as a set of three points , These points Each are not identical And Not in a straight line .
Example 1:
Input :points = [[1,1],[2,3],[3,2]]
Output :true
Example 2:
Input :points = [[1,1],[2,2],[3,3]]
Output :false
Tips :
points.length == 3
points[i].length == 2
0 <= xi, yi <= 100
source : Power button (LeetCode)
link :https://leetcode.cn/problems/valid-boomerang
Copyright belongs to the network . For commercial reprint, please contact the official authority , Non-commercial reprint please indicate the source .
Their thinking :
* Their thinking : * First, compare the three points to see if they overlap . * Then judge whether all three points are X Same axial direction . * Finally, the three points are subtracted by two ,Y Axis difference divided by X Axis difference , See if it's the same .
Code :
public boolean isBoomerang(int[][] points) {
int[] point0 = points[0];
int[] point1 = points[1];
int[] point2 = points[2];
if (point0[0] == point1[0] && point0[1] == point1[1]) {
return false;
}
if (point0[0] == point2[0] && point0[1] == point2[1]) {
return false;
}
if (point1[0] == point2[0] && point1[1] == point2[1]) {
return false;
}
if (point0[0] == point1[0] || point0[0] == point2[0]) {
return point0[0] != point1[0] || point0[0] != point2[0];
}
return (double)(point0[1] - point1[1]) / (double)(point0[0] - point1[0]) != (double)(point0[1] - point2[1]) / (double)(point0[0] - point2[0]);
}边栏推荐
- C asynchronous programming from simple to deep (III) details awaiter
- ACL2022 | DCSR:一种面向开放域段落检索的句子感知的对比学习方法
- Force deduction solution summary 473 match to square
- Leetcode 45 jump game II
- Force deduction solution summary - Sword finger offer II 114 Alien dictionary
- The release of star ring kundb 2.2 provides a new choice for business systems with high concurrent transactions and queries
- SQL calculates KS, AUC, IV, psi and other risk control model indicators
- 力扣解法汇总821-字符的最短距离
- Force deduction solution summary 398 random number index
- matplotlib. pyplot. Bar chart (II)
猜你喜欢

MySQL advanced knowledge points

How to automatically color cells in Excel

Installing MySQL version 5.5 database for Linux (centos6)

混泥土(地面+墙面)+ 山体裂缝数据集汇总(分类及目标检测)

DDD的分层架构

How WPS inserts a directory and the operating steps for quickly inserting a directory

Does the virtual host have independent IP

UE4\UE5触摸屏touch事件:单指、双指

Implementation scheme of iteration and combination pattern for general tree structure

Ozzanation - système d'action basé sur sse
随机推荐
Three main factors determining advertising quality
力扣解法汇总473-火柴拼正方形
2022西式面点师(技师)复训题库及在线模拟考试
Xcall cluster script (view JPS command)
Graphical data analysis | data analysis tool map
xcall 集群脚本(查看jps命令)
DDD的分层架构
Graphical data analysis | business analysis and data mining
力扣解法汇总713- 乘积小于 K 的子数组
力扣解法汇总388-文件的最长绝对路径
PHP development 09 article module deletion and article classification writing
Does the virtual host have independent IP
力扣解法汇总883-三维形体投影面积
How should programmers solve the problem of buying vegetables? Take you hand in hand to quickly order and grab vegetables by using the barrier free auxiliary function
Swiftyjson parsing local JSON files
Graphic data analysis | business cognition and data exploration
“中国东信杯”广西大学第四届程序设计竞赛(同步赛)
Force deduction solution summary - Sword finger offer II 114 Alien dictionary
How to maximize the use of various matching methods—— Google SEM
代理与反射(二)