समस्या
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
उदाहरण
इनपुट:
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.
इनपुट:
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 के लिए अनुकूलित की गई है। ऊपर दिए गए स्टेटमेंट और सीमाओं का पालन करें।