Skip to content

Commit 276ec9f

Browse files
authored
Create minimum-element-after-replacement-with-digit-sum.py
1 parent 3437ece commit 276ec9f

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Time: O(nlogr)
2+
# Space: O(1)
3+
4+
# array
5+
class Solution(object):
6+
def minElement(self, nums):
7+
"""
8+
:type nums: List[int]
9+
:rtype: int
10+
"""
11+
def f(x):
12+
result = 0
13+
while x:
14+
result += x%10
15+
x //= 10
16+
return result
17+
18+
return min(f(x) for x in nums)

0 commit comments

Comments
 (0)