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
Valid Boomerang Problem OverviewInput PointsCross Product CheckResult[1,1][2,3][3,2]Cross Product ≠ 0Not CollineartruePoints form a triangle → Valid Boomerang🎯 Key Insight: Use cross product to detect collinearity without division
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
Asked in
Google 15 Amazon 12 Microsoft 8
23.5K Views
Medium Frequency
~15 min Avg. Time
892 Likes
Ln 1, Col 1
Smart Actions
💡 Explanation
AI Ready
💡 Suggestion Tab to accept Esc to dismiss
// Output will appear here after running code
Code Editor Closed
Click the red button to reopen