题目:
题解:
class Solution {public int numberOfBoomerangs(int[][] points) {int ans = 0;for (int[] p : points) {Map<Integer, Integer> cnt = new HashMap<Integer, Integer>();for (int[] q : points) {int dis = (p[0] - q[0]) * (p[0] - q[0]) + (p[1] - q[1]) * (p[1] - q[1]);cnt.put(dis, cnt.getOrDefault(dis, 0) + 1);}for (Map.Entry<Integer, Integer> entry : cnt.entrySet()) {int m = entry.getValue();ans += m * (m - 1);}}return ans;}
}