447. Number of Boomerangs
class Solution:
def numberOfBoomerangs(self, points: List[List[int]]) -> int:
res = 0
for p1 in points:
d = defaultdict(int)
for p2 in points:
curDist = (p1[0] - p2[0]) ** 2 + (p1[1] - p2[1]) ** 2
if curDist in d:
res += d[curDist] * 2
d[curDist] += 1
return res