当前位置:网站首页>Force buckle 1037 Effective boomerang

Force buckle 1037 Effective boomerang

2022-07-07 20:06:00 Tomorrowave

1037. Effective boomerang

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

Ideas

Mathematical thought of three points collinear

Code section

class Solution:
    def isBoomerang(self, points: List[List[int]]) -> bool:
        o=points[0]
        points[1][0]-=points[0][0]
        points[1][1] -= points[0][1]
        points[2][0] -= points[0][0]
        points[2][1] -= points[0][1]
        res=points[1][0]*points[2][1]-points[1][1]*points[2][0]
        return res !=0
原网站

版权声明
本文为[Tomorrowave]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/188/202207071753355523.html