Valid Boomerang
From LeetCode. Collinearity check. Solve the geometry problem "Valid Boomerang".
Examples
Input: [1,2,3]
Output: 0
Input: [2,3,4]
Output: 0
Hints
A boomerang is three distinct, non-collinear points. Compute the triangle area via the shoelace formula: area = x1·(y2−y3) + x2·(y3−y1) + x3·(y1−y2). If area ≠ 0, the points are not collinear.
Distinctness matters: if any two points are identical, the set cannot form a boomerang. Check that p0 ≠ p1, p1 ≠ p2, and p0 ≠ p2 before computing area.
Avoid checking slopes with division — a vertical line (dx=0) would divide by zero. The integer shoelace/area formula is exact and handles all orientations.
Valid Boomerang
**From LeetCode.** Collinearity check. Solve the geometry problem "Valid Boomerang".