Problème
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.
Contraintes
0 ≤ length ≤ 100,000; each value fits in a 64-bit integer
Exemples
Exemple 1
Entrée :
numbers = [3, -1, 0, 7, 2]
Sortie attendue :
expected = 3
Entrée :
std::vector<long long> numbers = {3, -1, 0, 7, 2};
Sortie attendue :
long long expected = 3;
Entrée :
long[] numbers = new long[] {3, -1, 0, 7, 2};
Sortie attendue :
long expected = 3;
Explication
3, 7 and 2 are positive: 3.
Exemple 2
Entrée :
numbers = [0, 0, -5]
Sortie attendue :
expected = 0
Entrée :
std::vector<long long> numbers = {0, 0, -5};
Sortie attendue :
long long expected = 0;
Entrée :
long[] numbers = new long[] {0, 0, -5};
Sortie attendue :
long expected = 0;
Explication
No value is above zero: 0.
Références
Ce défi a été adapté pour CodeUtility. Suivez l'énoncé et les contraintes ci-dessus.