Условие
Показать переводReturn the largest value in the list by checking each element once.
Implement array_maximum(numbers).
Input
numbers: A non-empty list of integers.
Output
Return the maximum.
Ограничения
1 ≤ length ≤ 100,000
Примеры
Пример 1
Ввод:
numbers = [3, 9, 2]
Ожидаемый вывод:
expected = 9
Ввод:
std::vector<long long> numbers = {3, 9, 2};
Ожидаемый вывод:
long long expected = 9;
Ввод:
long[] numbers = new long[] {3, 9, 2};
Ожидаемый вывод:
long expected = 9;
Пояснение
9 is larger than 3 and 2.
Пример 2
Ввод:
numbers = [-4, -1, -7]
Ожидаемый вывод:
expected = -1
Ввод:
std::vector<long long> numbers = {-4, -1, -7};
Ожидаемый вывод:
long long expected = -1;
Ввод:
long[] numbers = new long[] {-4, -1, -7};
Ожидаемый вывод:
long expected = -1;
Пояснение
With only negative values, -1 is the largest.
Ссылки
Это задание адаптировано для CodeUtility. Следуйте условию и ограничениям выше.