Sum of Odd Numbers (Set 13)

Easy

Given an array of integers nums, return the sum of all its odd values, or 0 when every value is even.

Sum of Odd Numbers (Set 13) — the data. This set runs 4 cases: nums holds arrays of 48–48 items, with values from -40 to 55. The hidden cases are the largest of the set.

Example 1

sumOddNumbers()
Input
nums = [33, 39, 29, 19, -30, 50, -9, -1, -32, 48, 55, 5, 18, -5, -12, -27, -16, 26, -37, 39, 11, 37, 8, 28, 7, -13, 30, 12, 7, 7, 24, -23, 17, 31, -14, 48, 49, 15, 44, 8, 45, 46, -20, 12, -34, -25, -28, -28]
Output
305

Why

`sumOddNumbers` returns `305` for this input.

Example 2

sumOddNumbers()
Input
nums = [-23, 0, -15, -8, -12, 37, -40, 14, -37, 4, -16, 10, 46, -8, -30, 54, 29, -23, -25, 25, 12, 49, -30, 32, 51, 0, 9, 54, 7, 22, -29, -9, -7, -26, 12, -37, 7, 19, -16, -15, 43, 10, 29, 24, 39, 10, 36, 50]
Output
124

Why

`sumOddNumbers` returns `124` for this input.
Constraints
2 <= nums.length <= 10^4
-10^3 <= nums[i] <= 10^3
Every case in this set must pass: the first two are visible on Run, the last two unlock on Submit.

Topics

ArraysMath

Implement sumOddNumbers in the editor and return the answer — printing it is never graded.