Count Even Numbers - aloalgo

Count Even Numbers

Very Easy

You are given an array of integers nums.

Your task is to count how many elements in nums are even.

You may assume that:

  • The array may be empty.

Return the count of even numbers in the array.

Example 1

Input
[1, 2, 3, 4, 5, 6]
Output
3
Explanation:

The even numbers are 2, 4, and 6, so the count is 3.

Example 2

Input
[1, 3, 5, 7]
Output
0
Explanation:

There are no even numbers in the array.

Example 3

Input
[2, 4, 6]
Output
3
Explanation:

All elements are even, so the count is 3.

Loading...
Input
[1, 2, 3, 4, 5, 6]
Output
3

Hello! I am your ✨ AI assistant. I can provide you hints, explanations, give feedback on your code, and more. Just ask me anything related to the problem you're working on!