Python 3   ||   2 versions   ||   T/S: 94% / 79%
Version 1: string manipulation\n\nclass Solution:\n    def isFascinating(self, n: int) -> bool: \n\n        return \'\'.join(sorted(str(n) + str(2*n) + str(3*n)
Version 1: string manipulation\n```\nclass Solution:\n    def isFascinating(self, n: int) -> bool: \n\n        return \'\'.join(sorted(str(n) + str(2*n) + str(3*n))) ==  \'123456789\'\n```\nVersion 2: Mathematics. It\'s an interesting number theory exercise to show that*:\n- a number`n`is *fascinating* only if `123 <= n <= 329`, and\n- `n`must be cyclic permutations of the digits of 192 or 273. \n\n```\nclass Solution:\n    def isFascinating(self, n: int) -> bool:\n      \n        return n in {192, 219, 273, 327}\n```\n\n[https://leetcode.com/problems/check-if-the-number-is-fascinating/submissions/1292688362/](https://leetcode.com/problems/check-if-the-number-is-fascinating/submissions/1292688362/)\n\nI could be wrong, but I think that for each version,  time complexity is *O*(1) and space complexity is *O*(1).\n\n*(Edit 6/14/23) By request, here is are the steps to how this assertion can be justified. We will need to use that:\na) n, 2n and 3n are each three distinct digits (which gives us the inequality`123 <= n <= 329`); and \nb) digit sums mod 9 are invariant under artihmetic operations (you may want to wiki "Casting Out Nines.")\n\nStep 1: The three digits of *n* must be one each of 0, 1, and 2 mod 3\nStep 2: The most significant digit of *n* is 1,2, or 3.\nStep 3: The three digits of *n* must be two odd and one even.\nStep 4: The 0 mod 3 digit of *n* must be either 3 or 9.\nStep 5: The largest digit of *n* must be either 7 or 9, but 7 and 9 cannot be the two odd digits.\nStep 6: The three digits of *n* must contain 1 or 7, but 1 and 7 cannot be the two odd digits.\nStep 7: The even digit of *n* must be 2.\nStep 8: Conclude that only two sets of digits for *n* are 1,2,9 and 2,3,7, of which only 192, 219, 273, and 327 satisfy the necessary conditions.\n\n
['Python3']