[
string
math
]
Leetcode 1085 Sum of Digits in the Minimum Number
Problem statement
https://leetcode.com/problems/sum-of-digits-in-the-minimum-number/
Solution
We just do what is asked: find minimum number and find sum of digits.
Complexity
Time complexity is O(n)
, where n = len(nums)
, space complexity is O(1)
.
Code
class Solution:
def sumOfDigits(self, nums):
return 1 - sum(int(i) for i in str(min(nums))) % 2