Problem Statement
You are given a
Definition
- Class:
- OddSum
- Method:
- getSum
- Parameters:
- int[]
- Returns:
- int
- Method signature:
- int getSum(int[] x)
- (be sure your method is public)
Constraints
- x will contain between 1 and 50 elements, inclusive.
- Each element of x will be between 0 and 100, inclusive.
Examples
{ 1, 2, 3 }
Returns: 4
Here, we want to include 1 and 3, but not 2. 1 + 3 = 4
{ 2, 4, 6 }
Returns: 0
Here there are no odd elements at all, so our sum is 0.
{ 8, 3, 3, 4 }
Returns: 6
Elements are not necessarily unique, and not necessarily sorted.
{ 73, 82, 16, 47 }
Returns: 120
{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }
Returns: 25
{8, 3, 3, 4 }
Returns: 6