Medium

Quiz

#447 Number of Boomerangs

APPROACH

You are given n distinct 2D points points[i] = [xi, yi]. A boomerang is an ordered triple of point indices (i, j, k) where the distance from i to j equals the distance from i to k. The order of j and k matters.

Return the total number of boomerangs.

Example 1:

Input: points = [[0,0],[1,0],[2,0]]
Output: 2
Explanation: The two boomerangs are [[1,0],[0,0],[2,0]] and [[1,0],[2,0],[0,0]].

Example 2:

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

Example 3:

Input: points = [[1,1]]
Output: 0
1 of 4
1:00

What is the optimal approach for this problem?