Logo
IconChallenge
Icon
IconProblem
IconSolutions
IconSubmissions

Number of Boomerangs

XPChallenge Points: 20
levelLevel: Medium

You are given a list of distinct points on a 2D plane. A boomerang is defined as an ordered triplet of points (i, j, k) such that the distance between point i and point j is the same as the distance between point i and point k.
Note that order matters, meaning (i, j, k) and (i, k, j) are considered different.

Return the total number of such boomerang triplets.

Example 1:

Input: points = [[0,0],[0,2],[2,0],[2,2]]

Output: 8

Explanation:

Several combinations around each center have equal distances.

Example 2:

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

Output: 8

Explanation:

Each point forms symmetric distances with its neighbors.

Example 3:

Input: points = [[2,3]]

Output: 0

Explanation:

Only one point → No possible triplets.

to Continue
like
dislike

Accepted:

Submission:

IconReport an issue
Icon
IconCode
IconYou need toto run or submitYou need toto run or submit
IconTest Case
IconTest Result