Skip to content

Practice Number of Boomerangs

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#447
LeetCode Problem

Number of Boomerangs

Problem Statement

You are given n points in the plane that are all distinct, where points[i] = [xi, yi]. A boomerang is a tuple of points (i, j, k) such that the distance between i and j equals the distance between i and k (the order of the tuple matters). Return the number of boomerangs.

Source: Number of Boomerangs on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
points = [[0,0],[1,0],[2,0]]
Output
2

# Example 2

Input
points = [[1,1],[2,2],[3,3]]
Output
2

# Example 3

Input
points = [[1,1]]
Output
0

Constraints

n == points.length
1 <= n <= 500
points[i].length == 2
-10^4 <= xi, yi <= 10^4
All the points are unique.

Related LeetCode Problems

Practice more problems similar to Number of Boomerangs.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.