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

Count Positive Numbers

Count the values greater than zero in a list.

Условие

Count how many numbers in the list are greater than zero. Zero is neither positive nor negative.

Implement count_positives(numbers).

Input

numbers: The list of integers.

Output

Return the count.

Ограничения

0 ≤ length ≤ 100,000; each value fits in a 64-bit integer

Примеры

Пример 1
Ввод:
numbers = [3, -1, 0, 7, 2]

Ожидаемый вывод:
expected = 3
Ввод:
std::vector<long long> numbers = {3, -1, 0, 7, 2};

Ожидаемый вывод:
long long expected = 3;
Ввод:
long[] numbers = new long[] {3, -1, 0, 7, 2};

Ожидаемый вывод:
long expected = 3;

Пояснение

3, 7 and 2 are positive: 3.

Пример 2
Ввод:
numbers = [0, 0, -5]

Ожидаемый вывод:
expected = 0
Ввод:
std::vector<long long> numbers = {0, 0, -5};

Ожидаемый вывод:
long long expected = 0;
Ввод:
long[] numbers = new long[] {0, 0, -5};

Ожидаемый вывод:
long expected = 0;

Пояснение

No value is above zero: 0.

Ссылки

Это задание адаптировано для CodeUtility. Следуйте условию и ограничениям выше.

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

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

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