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
'IT > 코딩테스트' 카테고리의 다른 글
[Leetcode] 57. Insert Interval (0) | 2024.03.17 |
---|---|
[Leetcode] 3083. Existence of a Substring in a String and Its Reverse (0) | 2024.03.17 |
[Leetcode] 525. Contiguous Array (0) | 2024.03.16 |
[Leetcode] 238. Product of Array Except Self (0) | 2024.03.15 |
[Leetcode] 930. Binary Subarrays With Sum (1) | 2024.03.14 |