Skip to content
LC-3300 Easy LeetCode

3300. Minimum Element After Replacement With Digit Sum

Read the full problem statement on LeetCode.
Difficulty: easy Acceptance: 83% Topics: Array, Math
View full problem on LeetCode
Reference solution (spoiler · python)
# Time:  O(nlogr)
# Space: O(1)

# array
class Solution(object):
    def minElement(self, nums):
        """
        :type nums: List[int]
        :rtype: int
        """
        def f(x):
            result = 0
            while x:
                result += x%10
                x //= 10
            return result

        return min(f(x) for x in nums)

Solution from kamyu104/LeetCode-Solutions · MIT