IT/코딩테스트
[Leetcode] 3079. Find the Sum of Encrypted Integers
이주디
2024. 3. 16. 23:47
728x90
https://leetcode.com/problems/find-the-sum-of-encrypted-integers/
class Solution:
def sumOfEncryptedInt(self, nums: List[int]) -> int:
encrypted_nums = []
for n in nums:
ndigit = list(map(int, str(n)))
if len(ndigit) > 1:
max = -1
for i in ndigit:
if max < i:
max = i
encrypted = int(str(max) * len(ndigit))
encrypted_nums.append(encrypted)
else:
encrypted_nums.append(n)
sum = 0
for n in encrypted_nums:
sum += n
return sum
728x90