0%

[題解]Leetcode 1037 Valid Boomerang

1037 Valid Boomerang

題目連結

1
2
3
4
5
6
7
8
9
10
class Solution {
public:
bool isBoomerang(vector<vector<int>>& points) {
int x1 = points[1][0]-points[0][0],y1 = points[1][1]-points[0][1];
int x2 = points[2][0]-points[1][0],y2 = points[2][1]-points[1][1];
int cross = x1 * y2 - x2 * y1;
if(cross == 0)return false;
return true;
}
};