← 返回 linkedin 的题目列表Find the Minimum Distance Point
类型:online_judge
Given a one-dimensional integer array, find a point such that the sum of the distances from this point to all the points in the array is minimized. Implement a function to achieve this and output the minimum sum of distances. Assume there is at least one element in the array.
Input
A one-dimensional integer array points, e.g., [1, 2, 3, 4, 5].
Output
An integer representing the minimum sum of distances.
Example
Input: [1, 2, 3]
Output: 2
Constraints
Array length: 1 <= points.length <= 10^5
Element value range: -10^4 <= points[i] <= 10^4.
Example
Input
1,2,3