Isaac Emmanuel
09 Sept 2026•EasyGo / Python / TypeScript

Valid Boomerang

Check whether three two-dimensional points are distinct and non-collinear.

Compute the cross product of the two vectors from the first point; a nonzero value means the triangle has positive area.

Complexity

O(1) time and O(1) space.

Solution files

Go•valid-boomerang/solution.go
package main

func isBoomerang(points [][]int) bool {
	return (points[1][0]-points[0][0])*(points[2][1]-points[0][1]) != (points[1][1]-points[0][1])*(points[2][0]-points[0][0])
}
Python•valid-boomerang/solution.py
class Solution:
    def isBoomerang(self, points: list[list[int]]) -> bool:
        return (points[1][0] - points[0][0]) * (points[2][1] - points[0][1]) != (points[1][1] - points[0][1]) * (points[2][0] - points[0][0])
TypeScript•valid-boomerang/solution.ts
function isBoomerang(points: number[][]): boolean {
  return (points[1][0] - points[0][0]) * (points[2][1] - points[0][1]) !== (points[1][1] - points[0][1]) * (points[2][0] - points[0][0]);
}