-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1037. Valid Boomerang.cpp
More file actions
45 lines (32 loc) · 1 KB
/
1037. Valid Boomerang.cpp
File metadata and controls
45 lines (32 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//link: https://leetcode.com/problems/valid-boomerang/
/*
A boomerang is a set of 3 points that are all distinct and not in a straight line.
Given a list of three points in the plane, return whether these points are a 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] <= 100
*/
/*
Result:
Runtime: 0 ms, faster than 100.00% of C++ online submissions for Valid Boomerang.
Memory Usage: 6.2 MB, less than 100.00% of C++ online submissions for Valid Boomerang.
*/
class Solution {
public:
bool isBoomerang(vector<vector<int>>& points) {
if(points[0] == points[1] || points[0] == points[2] || points[1] == points[2]){
return false;
}
if((points[2][1] - points[0][1]) * (points[1][0] - points[0][0]) == (points[1][1] - points[0][1]) * (points[2][0] - points[0][0])){
return false;
}
return true;
}
};