#447
Number of Boomerangs
specialist · 825 · lc medium +31 · verified · 57.3% accepted · 897 likes · top 53%
Description
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
Code
1
2
3