問題
Compute the average of the list, then keep only the values strictly greater than it, in their original order.
Implement above_average(numbers).
Input
numbers: The list of integers.
Output
Return the values above the average (an empty list for an empty input).
制約
0 ≤ length ≤ 10,000; -1,000,000 ≤ each value ≤ 1,000,000
例
例 1
入力:
numbers = [1, 2, 3, 4, 10]
期待される出力:
expected = [10]
入力:
std::vector<long long> numbers = {1, 2, 3, 4, 10};
期待される出力:
std::vector<long long> expected = {10};
入力:
long[] numbers = new long[] {1, 2, 3, 4, 10};
期待される出力:
long[] expected = new long[] {10};
解説
The average is 20 / 5 = 4; only 10 is greater than 4.
例 2
入力:
numbers = [5, 5, 5]
期待される出力:
expected = []
入力:
std::vector<long long> numbers = {5, 5, 5};
期待される出力:
std::vector<long long> expected = {};
入力:
long[] numbers = new long[] {5, 5, 5};
期待される出力:
long[] expected = new long[] {};
解説
Every value equals the average 5, so none is greater: [].
参考資料
この課題はCodeUtility用に調整されています。上記の説明と制約に従ってください。