当前位置:网站首页>Daily question -leetcode1037- effective boomerang

Daily question -leetcode1037- effective boomerang

2022-06-09 11:41:00 Li Fan, hurry up

Original link
 Insert picture description here

Note:

The result of cross product is 0, Description collinear , Otherwise, it means that they are not collinear
The cross product of three vectors is too much trouble , Change to two calculations

The code is as follows :

class Solution {
    
public:
    bool isBoomerang(vector<vector<int>>& points) {
    
        int x1 = points[0][0], y1 = points[0][1];
        int x2 = points[1][0], y2 = points[1][1];
        int x3 = points[2][0], y3 = points[2][1];
        int a = x2 - x1, b = y2 - y1;
        int c = x3 - x1, d = y3 - y1;
        if(a * d - b * c == 0)  return false;
        return true;
    }
};
原网站

版权声明
本文为[Li Fan, hurry up]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/160/202206091055525528.html