본문 바로가기
python-algorithm

leetcode 2729. Check if The Number is Fascinating

by 무적김두칠 2023. 12. 29.

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
반응형

댓글