Valid Boomerang - Problem
Given an array points where points[i] = [x_i, y_i] represents a point on the X-Y plane, return true if these points form a boomerang.
A boomerang is a set of three points that are all distinct and not in a straight line.
Input & Output
Example 1 — Valid Boomerang
$
Input:
points = [[1,1],[2,3],[3,2]]
›
Output:
true
💡 Note:
The three points are distinct and not collinear, so they form a valid boomerang. Cross product calculation: (2-1)×(2-1) - (3-1)×(3-1) = 1×1 - 2×2 = -3 ≠ 0
Example 2 — Collinear Points
$
Input:
points = [[1,1],[2,2],[3,3]]
›
Output:
false
💡 Note:
All three points lie on the same straight line (y = x), so they cannot form a boomerang. Cross product: (2-1)×(3-1) - (2-1)×(3-1) = 1×2 - 1×2 = 0
Example 3 — Duplicate Points
$
Input:
points = [[1,1],[2,3],[1,1]]
›
Output:
false
💡 Note:
Two points are identical ([1,1] appears twice), so they cannot form a valid boomerang. Cross product: (2-1)×(1-1) - (3-1)×(1-1) = 1×0 - 2×0 = 0
Constraints
- points.length == 3
- points[i].length == 2
- 0 ≤ points[i][j] ≤ 50
Visualization
Tap to expand
Understanding the Visualization
1
Input
Three points on 2D plane: [[1,1],[2,3],[3,2]]
2
Process
Check if points are distinct and not on same line
3
Output
Return true if valid boomerang, false otherwise
Key Takeaway
🎯 Key Insight: Cross product elegantly detects collinearity without division edge cases
💡
Explanation
AI Ready
💡 Suggestion
Tab
to accept
Esc
to dismiss
// Output will appear here after running code