2025-08-22 16:14:44 +0000 UTC

Find the Sum of Encrypted Integers

Code

class Solution:
    def sumOfEncryptedInt(self, nums: List[int]) -> int:
        res = 0
        for i in range(len(nums)):
            cur = nums[i]
            max_dig = 0
            enc = 0
            cnt = 0
            while cur > 0:
                max_dig = max(max_dig, cur % 10)
                cur //= 10
                enc += 10 ** cnt
                cnt += 1
            enc *= max_dig
            res += enc
        return res