← 返回 linkedin 的题目列表Find the Median Point on a Line
类型:online_judge
Given a line with many points, find a point such that the sum of distances from this point to all other points is minimized. Implement a function that, given a list of integer coordinates, returns the position of this point. Assume the input is a list of integer coordinates.
Example:
Input: points = [1, 2, 3]
Output: 2
Explanation: The sum of distances from point 2 to other points (1->2 + 2->2 + 3->2) is minimized.
Constraints:
1 <= points.length <= 10^5
-10^4 <= points[i] <= 10^4
Example
Input
1 2 3