https://leetcode.com/problems/find-the-key-of-the-numbers/description/
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
class Solution:
def generateKey(self, num1: int, num2: int, num3: int) -> int:
str_num1, str_num2, str_num3 = str(num1), str(num2), str(num3)
max_length = max(len(str_num1), len(str_num2), len(str_num3))
str_num1 = str_num1.zfill(max_length)
str_num2 = str_num2.zfill(max_length)
str_num3 = str_num3.zfill(max_length)
answer = ""
for i in range(max_length):
answer += str(min(int(str_num1[i]), int(str_num2[i]), int(str_num3[i])))
return int(answer)
|
cs |
반응형
'python-algorithm' 카테고리의 다른 글
leetcode 3280. Convert Date to Binary (1) | 2024.09.12 |
---|---|
leetcode 1684. Count the Number of Consistent Strings (0) | 2024.09.12 |
백준 31994 강당 대관 (0) | 2024.07.15 |
백준 32025 체육은 수학과목 입니다 (0) | 2024.07.15 |
백준 30979 유치원생 파댕이 돌보기 (0) | 2024.06.19 |
댓글