Skip to content

Commit b30e77f

Browse files
authored
Added rust code for SumOfDigitsInTheMinimumNumber
1 parent 81a3e20 commit b30e77f

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
impl Solution {
2+
pub fn sum_of_digits(nums: Vec<i32>) -> i32
3+
{
4+
let mut min = *nums.iter().min().unwrap();
5+
6+
// iterate over digits adding to sum
7+
let mut digitSum = 0;
8+
while min > 0
9+
{
10+
let digit = min % 10;
11+
digitSum += digit;
12+
13+
// iterate to next digit
14+
min /= 10;
15+
}
16+
17+
return if digitSum % 2 == 0 { 1 } else { 0 };
18+
}
19+
}

0 commit comments

Comments
 (0)