Skip to content

Commit 9cac67d

Browse files
authored
Create solution.cpp
1 parent 0f90a85 commit 9cac67d

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
class Solution {
2+
public:
3+
int sumOfDigits(vector<int>& nums)
4+
{
5+
int min = *min_element(nums.begin(), nums.end());
6+
7+
// iterate over digits adding to sum
8+
int digitSum = 0;
9+
while (min > 0)
10+
{
11+
int digit = min % 10;
12+
digitSum += digit;
13+
14+
// iterate to next digit
15+
min /= 10;
16+
}
17+
18+
return (digitSum % 2 == 0);
19+
}
20+
};

0 commit comments

Comments
 (0)