##### Welcome to Subscribe On Youtube

Formatted question description: https://leetcode.ca/all/1037.html

# 1037. Valid Boomerang (Easy)

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:

1. points.length == 3
2. points[i].length == 2
3. 0 <= points[i][j] <= 100

Companies:

Related Topics:
Math

## Solution 1.

• class Solution {
public boolean isBoomerang(int[][] points) {
int difX1 = points - points, difY1 = points - points;
int difX2 = points - points, difY2 = points - points;
return difX1 * difY2 != difX2 * difY1;
}
}

############

class Solution {
public boolean isBoomerang(int[][] points) {
int x1 = points, y1 = points;
int x2 = points, y2 = points;
int x3 = points, y3 = points;
return (y2 - y1) * (x3 - x2) != (y3 - y2) * (x2 - x1);
}
}

• // OJ: https://leetcode.com/problems/valid-boomerang
// Time: O(1)
// Space: O(1)
class Solution {
public:
bool isBoomerang(vector<vector<int>>& points) {
return (points - points) * (points - points) != (points - points) * (points - points);
}
};

• class Solution:
def isBoomerang(self, points: List[List[int]]) -> bool:
(x1, y1), (x2, y2), (x3, y3) = points
return (y2 - y1) * (x3 - x2) != (y3 - y2) * (x2 - x1)

############

# 1037. Valid Boomerang
# https://leetcode.com/problems/valid-boomerang/

class Solution:
def isBoomerang(self, p: List[List[int]]) -> bool:
return (p - p) * (p - p) != (p - p) * (p - p)


• func isBoomerang(points [][]int) bool {
x1, y1 := points, points
x2, y2 := points, points
x3, y3 := points, points
return (y2-y1)*(x3-x2) != (y3-y2)*(x2-x1)
}

• function isBoomerang(points: number[][]): boolean {
const [x1, y1] = points;
const [x2, y2] = points;
const [x3, y3] = points;
return (x1 - x2) * (y2 - y3) !== (x2 - x3) * (y1 - y2);
}


• impl Solution {
pub fn is_boomerang(points: Vec<Vec<i32>>) -> bool {
let (x1, y1) = (points, points);
let (x2, y2) = (points, points);
let (x3, y3) = (points, points);
(x1 - x2) * (y2 - y3) != (x2 - x3) * (y1 - y2)
}
}