Array Sum Even Check - aloalgo

Array Sum Even Check

Very Easy

You are given an integer array nums.

Your task is to determine whether the sum of all elements in the array is even.

You may assume that:

  • The array can be empty, in which case the sum is 0 (which is even).

Return true if the sum is even, otherwise return false.

Example 1

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

The sum is 2 + 4 + 6 = 12, which is even, so we return true.

Example 2

Input
[1, 2, 4]
Output
False
Explanation:

The sum is 1 + 2 + 4 = 7, which is odd, so we return false.

Example 3

Input
[1, 3, 5, 1]
Output
True
Explanation:

The sum is 1 + 3 + 5 + 1 = 10, which is even, so we return true.

Loading...
Input
[2, 4, 6]
Output
True

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!