https://leetcode.com/problems/harshad-number/description/
1 2 3 4 5 6 7 8 | class Solution: def sumOfTheDigitsOfHarshadNumber(self, x: int) -> int: new_number = sum(list(map(int, list(str(x))))) if x % new_number == 0: return new_number else: return -1 | cs |
반응형
'python-algorithm' 카테고리의 다른 글
leetcode 3079. Find the Sum of Encrypted Integers (0) | 2024.04.24 |
---|---|
leetcode 3083. Existence of a Substring in a String and Its Reverse (0) | 2024.04.24 |
leetcode 3046. Split the Array (0) | 2024.04.22 |
leetcode 3110. Score of a String (0) | 2024.04.22 |
백준 27736 찬반투표 (0) | 2024.04.21 |
댓글