Đề bài
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.
Ràng buộc
0 ≤ length ≤ 100,000; each value fits in a 64-bit integer
Ví dụ
Ví dụ 1
Đầu vào:
numbers = [3, -1, 0, 7, 2]
Kết quả mong đợi:
expected = 3
Đầu vào:
std::vector<long long> numbers = {3, -1, 0, 7, 2};
Kết quả mong đợi:
long long expected = 3;
Đầu vào:
long[] numbers = new long[] {3, -1, 0, 7, 2};
Kết quả mong đợi:
long expected = 3;
Giải thích
3, 7 and 2 are positive: 3.
Ví dụ 2
Đầu vào:
numbers = [0, 0, -5]
Kết quả mong đợi:
expected = 0
Đầu vào:
std::vector<long long> numbers = {0, 0, -5};
Kết quả mong đợi:
long long expected = 0;
Đầu vào:
long[] numbers = new long[] {0, 0, -5};
Kết quả mong đợi:
long expected = 0;
Giải thích
No value is above zero: 0.
Tham khảo
Thử thách này đã được điều chỉnh cho CodeUtility. Hãy làm theo đề bài và các ràng buộc ở trên.