← 返回 linkedin 的题目列表Minimum Travel Distance
类型:online_judge
Given a list of integers representing the travel distance of each person to point 0, determine a meeting point that minimizes the total travel distance for all individuals. Calculate and return this minimal total travel distance. Assume all points are on a straight line.
Input
List[int]: List of travel distances
Output
int: Minimum total travel distance
Test Cases
# Input: [1, 2, 3]
# Output: 2
# Input: [1, 0, 4, 6]
# Output: 8
# Input: [5, 10, 15]
# Output: 10
# Input: [2, 2, 2]
# Output: 0
# Input: [1, 6, 11]
# Output: 10
Constraints
Number of elements n is in the range [1, 10^5]
Element values are non-negative integers and less than or equal to 10^5.
Example
Input
[1, 2, 3]