Number of Boomerangs LeetCode solution in Python
1class Solution:2def numberOfBoomerangs(self, points: List[List[int]]) -> int:3def sq(a):4return a * a56def euclid(a, b, c, d):7dist = sq(a - c) + sq(b - d)8return sq(dist)910n = len(points)11res = 012for i in range(n):13count = defaultdict(lambda: 0)14for j in range(n):15d = euclid(points[i][0], points[i][1], points[j][0], points[j][1])16res += count[d] * 217count[d] += 11819return res