본문 바로가기
python-algorithm

leetcode 3079. Find the Sum of Encrypted Integers

by 무적김두칠 2024. 4. 24.

https://leetcode.com/problems/find-the-sum-of-encrypted-integers/description/

 

1
2
3
4
5
6
7
8
9
10
class Solution:
    def sumOfEncryptedInt(self, nums: List[int]) -> int:
        answer = 0
        for num in nums:
            str_num = str(num)
            max_digit = str(max(map(int, list(str_num))))
            tmp_answer = int(max_digit * len(str_num))
            answer += tmp_answer
        return answer
        
cs
반응형

댓글