given n points in the plane that's all pairwise distinct, a" boomerang "is a tuple of POINTS  (I, J, K) such that the distance between i and j equals the distance between i and k ( the order of the tuple matters ).
Find the number of boomerangs. Assume that n would be is at most and coordinates of points is all in the range [-10000, 10 (inclusive).
Example:
Input: [[0,0],[1,0],[2,0]] Output:2explanation:[[1,0],[0,0],[2,0]][[1,0],[2,0],[0,0]]
Test instructions: Defines a ternary structure similar to "back-shaped", that is, the distance between I and J in the ternary group (I, J, K) is equal to the distance between I and K. Find a set of coordinate data that can form several sets of such "back-up" structures.
Idea: Traverse each point, use the dictionary to store the number of points in the same distance according to the quantity, using the permutation combination formula N (N-1), calculate the number of possible components of the boomerang
For those that don ' t understand how GroupCount * (GroupCount + 1) became N * (N-1):
Algorithm actually sets GroupCount to zero for the first point, 1 for the second point, etc. So, if N = = GroupCount + 1
N * (N - 1)== (groupCount + 1) * ((groupCount + 1) - 1)== (groupCount + 1) * (groupCount)== groupCount * (groupCount + 1)
static public int NumberOfBoomerangs(int[,] points) {
int number = 0;
int disSqrt = 0;
int count = points.GetLength(0);
for (int i = 0; i < count; i++) {
dictionary < int int > dic = new dictionary < int int > ();
for (int j = 0; j < count; j++) {
if (i == j) {
continue;
}
dissqrt= (points[I, 0] -points[J, 0]) * (points[I, 0] -points[J, 0]) -
(points[I, 1] -points[J, 1]) * (points[I, 1] -points[J, 1]);
if (dic.ContainsKey(disSqrt)) {
dic[disSqrt]++;
} else {
dic[disSqrt] = 0;
}
}
foreach (int value in dic.Values) {
number += value * (value + 1);
}
}
return number;
}
Https://discuss.leetcode.com/topic/67102/c-hashtable-solution-o-n-2-time-o-n-space-with-explaination/2
Https://discuss.leetcode.com/topic/68139/simple-java-solution-using-hashmap-beats-90/3
From for notes (Wiz)
447. Calculate the number of boomerang coordinates numberofboomerangs