← 返回 amazon 的题目列表Calculate Median of Integer Array Success Values
类型:online_judge
amazon
Problem: Success Value Calculation
Given an integer array values, representing a list of success values. Calculate and return the median of these success values. The median is calculated as the traditional way: if the list length is odd, it is the middle number of the sorted array; if it is even, it's the average of the two middle numbers.
Input:
An integer array values, with length $1 \leq n \leq 10^5$, and each integer is $0 \leq values[i] \leq 10^9$.
Output:
A float representing the median of the success values.
Example:
Input: [1, 2, 3, 4, 5] Output: 3.0
Input: [1, 2, 3, 4] Output: 2.5
Example
Input
1 2 3 4 5