You are working for a defense agency that is testing the accuracy of a new missile guidance system. As
part of this effort, several missiles have been fired off. Each missile fired was programmed with the
same target coordinates, although the actual points of impact vary.
Your task is to determine the "best fit" point to describe the location where the missiles actually
landed. To determine how well a point describes the location, calculate the cartesian distance from the
point to each of the landing points. Then, total the sum of the squares of these distances. The best
fit point is the point that minimizes this sum.
You are given int[]s x and y, both containing the same number of elements,
where the i-th element of x and the i-th element of y describe the coordinates of the i-th
missile landing point. You are to return a int[] with exactly two elements, describing the
coordinates of the lattice point (point with integral coordinates) that is closest to the "best fit" point. The first element should be the x-coordinate, and the second
element should be the y-coordinate. |