Все задачи
Легко Решено: 0 Процент решений: 0%

Above-Average Values

Keep the values that are greater than the average.

Условие

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. Следуйте условию и ограничениям выше.

Учитесь у других

Решения сообщества

Пока нет опубликованных решений. Решите задание, чтобы поделиться первым.