https://leetcode.com/problems/check-if-the-number-is-fascinating/description/
Check if The Number is Fascinating - LeetCode
Can you solve this real interview question? Check if The Number is Fascinating - You are given an integer n that consists of exactly 3 digits. We call the number n fascinating if, after the following modification, the resulting number contains all the digi
leetcode.com
1 2 3 4 5 6 7 8 9 10 | class Solution: def isFascinating(self, n: int) -> bool: num = list(str(n) + str(n*2) + str(n*3)) set_num = list(set(num)) if len(set_num) == 9 and len(num) == 9 and '0' not in set_num: return True else: return False | cs |
반응형
'python-algorithm' 카테고리의 다른 글
leetcode 2788. Split Strings by Separator (1) | 2024.01.02 |
---|---|
leetcode 2824. Count Pairs Whose Sum is Less than Target (1) | 2024.01.02 |
leetcode 2903. Find Indices With Index and Value Difference I (0) | 2023.12.28 |
leetcode 2923. Find Champion I (0) | 2023.12.28 |
leetcode 2697. Lexicographically Smallest Palindrome (1) | 2023.12.28 |
댓글