#1037
Easy Algorithms Valid boomerang
Array Math Geometry
39.2% acceptance
Feb 25, 2026
462
543
Given an array points where points[i] = [xi, yi] represents a point on the X-Y plane, return true if these points are a boomerang.
A boomerang is a set of three points that are all distinct and not in a straight line.
Solution
Rust
Time O(1)
Space O(1)
impl Solution {
pub fn is_boomerang(points: Vec<Vec<i32>>) -> bool {
let (dx1, dy1) = (points[1][0]-points[0][0], points[1][1]-points[0][1]);
let (dx2, dy2) = (points[2][0]-points[0][0], points[2][1]-points[0][1]);
dx1 * dy2 != dx2 * dy1
}
}