1037.Valid Boomerang
Example 1:
Input: [[1,1],[2,3],[3,2]]
Output: true
Example 2:
Input: [[1,1],[2,2],[3,3]]
Output: false
Note:
points.length == 3
points[i].length == 2
0 <= points[i][j] <= 100Last updated
Example 1:
Input: [[1,1],[2,3],[3,2]]
Output: true
Example 2:
Input: [[1,1],[2,2],[3,3]]
Output: false
Note:
points.length == 3
points[i].length == 2
0 <= points[i][j] <= 100Last updated
class Solution {
public:
bool isBoomerang(vector<vector<int>>& points) {
int a=points[1][1]-points[0][1];
int b=points[1][0]-points[0][0];
int c=points[2][1]- points[0][1];
int d=points[2][0]-points[0][0];
// cout<<a<<" "<<b<<" "<<c<<" " << d<<endl;
if(b && d)
return a/float(b)!=c/float(d);
else if(b)
return c;
else if (d)
return a;
else
return false;
}
};