728x90
▼ 문제 바로가기 (링크) ▼
https://leetcode.com/problems/minimum-sum-of-four-digit-number-after-splitting-digits/
class Solution:
def minimumSum(self, num: int) -> int:
num = str(num)
num_list = []
for i in range(4):
num_list.append(num[i])
num_list.sort()
a = int(num_list[0] + num_list[2])
b = int(num_list[1] + num_list[3])
answer = a+b
return answer
Memory Usage: 13.8 MB, less than 57.11%
728x90
반응형
'코딩 테스트 > leetCode' 카테고리의 다른 글
[leetCode] 1512. Number of Good Pairs (Python) (0) | 2022.10.18 |
---|---|
[leetCode] 13. Roman to Integer (Python) (0) | 2022.10.14 |
[leetCode] 2114. Maximum Number of Words Found in Sentences (Python) (0) | 2022.10.12 |
[leetCode] 2413. Smallest Even Multiple (Python) (0) | 2022.10.12 |
[leetCode] 1470. Shuffle the Array (Python) (0) | 2022.10.12 |